Closed Bug 756965 Opened 8 years ago Closed 8 years ago

mozilla::ThreadLocal only allows pointers

Categories

(Core :: MFBT, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla15

People

(Reporter: glandium, Assigned: glandium)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

There are several cases, including the examples given in ThreadLocal.h, where ThreadLocal may be used with integer types, which is actually not possible with the current implementation (which makes the example code wrong). Also, since the type given to the template is not exactly the one returned by get() and taken by set(), it's not entirely clear when writing a ThreadLocal variable definition what its type actually is.
Comment on attachment 625561 [details] [diff] [review]
Allow mozilla::ThreadLocal to store integer types smaller than, or as large as, a pointer

Review of attachment 625561 [details] [diff] [review]:
-----------------------------------------------------------------

Seems reasonable.

::: mfbt/ThreadLocal.h
@@ +74,5 @@
>  
> +    typedef union {
> +      void *ptr;
> +      T value;
> +    } helper;

Just |union Helper|, please.  The typedef here is unnecessary, since everything using this is a member of ThreadLocal for name lookup purposes.  And it should be InterCaps-named like everything else.
Attachment #625561 - Flags: review?(jwalden+bmo) → review+
https://hg.mozilla.org/mozilla-central/rev/b3570567bd5d
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.