is core Mutex lock "fast"?
IGotD-
nise at nise.com
Tue Jan 26 21:49:41 UTC 2021
On Tuesday, 26 January 2021 at 21:09:34 UTC, Steven Schveighoffer
wrote:
>
> 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
Yes, I didn't see the lock would block subsequent threads.
Both pthread_mutex_lock and EnterCriticalSection do exactly the
same as FastLock and the only difference is the the check is
"closer" to the running code. Performance increase should be low.
As I was wrong about the thread safety, I will not write here any
further.
More information about the Digitalmars-d-learn
mailing list