is core Mutex lock "fast"?

Steven Schveighoffer schveiguy at gmail.com
Tue Jan 26 21:09:34 UTC 2021


On 1/26/21 3:56 PM, IGotD- wrote:

> That code isn't thread safe at all (assuming FastLock is used from 
> several threads). lockCount isn't atomic which means the code will not 
> work with several threads.> Also the assignment of the variable owner 
> isn't thread safe. As soon you start to include more that one supposedly 
> atomic assignment in synchronization primitives, things quickly get out 
> of hand.

The only item that is read without being locked is owner. If you change 
that to an atomic read and write, it should be fine (and is likely fine 
on x86* without atomics anyway).

All the other data is protected by the actual mutex, and so should be 
synchronous.

However, I think this is all moot, druntime is the same as Tango.

-Steve


More information about the Digitalmars-d-learn mailing list