[llvm-commits] [PATCH] Thread-safe ManagedStatic
resistor at mac.com
Tue May 19 04:29:05 PDT 2009
On May 19, 2009, at 4:26 AM, Owen Anderson wrote:
>> 3. Why do you create your own mutex out of atomic operations instead
>> of just using a pthreads lock? spinning is not always an efficient
>> solution to contention, particularly if your machine really only has
>> one cpu! (in which case you end up spinning away the rest of your
> Portability. llvm::sys::Mutex _cannot_ be made to work, because on
> it has to have a non-trivial constructor.
To build on my own comment, this is also the reason behind having one
object. Since we have to write our own mutex implementation for this
to work on Windows,
we are free to write one that uses zero as the unlocked state, and can
thus be put within
each ManagedStatic, reducing lock contention.
Basically, given that we need to implement our own mutex, making one-
seems like the natural next step.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2620 bytes
Desc: not available
More information about the llvm-commits