shared Mutex?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 9 13:58:08 PDT 2016


On 6/9/16 2:31 PM, cy wrote:

> Is core.sync.mutex.Mutex even usable in D anymore? It seems every mutex
> that wasn't shared would be part of thread local data, so two threads
> locking on the same mutex would actually be locking separate mutexes.

Yes, but this is because Mutex existed way before shared did.

IMO Mutex should be ALWAYS shared. As you suggest, an unshared mutex is 
a useless thing.

You can have data that is shared, but not actually typed as shared, 
which is what Mutex traditionally works with.

This is a bug that needs to be fixed -- everything in core.sync should 
work with shared and unshared types. And then we should eventually get 
rid of (or turn into no-ops) the unshared members.

-Steve


More information about the Digitalmars-d-learn mailing list