`shared Mutex`?

Aiden via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Dec 28 01:24:29 PST 2014


Hello all,

This is my first post on these forums. I've been learning D for 
the past couple of months or so and have been quite impressed by 
the language thus far. One stumbling block that I have 
encountered is with using `shared`, and more specifically using 
`shared` with synchronization tools like Mutex and Condition.

Consider the following program:
https://gist.github.com/anibali/4d544c31ac762409d4ea

I can't seem to get the thing working without a bunch of casts to 
and from `shared`, which I'm assuming is not a good practice - it 
definitely doesn't make for nice-looking code.

I've found an old thread on a similar 
issue(http://forum.dlang.org/thread/moyyibrpnnmrrovylkui@forum.dlang.org) 
but there doesn't seem to be a conclusion there either.

Is `shared` in a workable state? Shouldn't Mutex, Condition, etc 
be shared since they are basically only ever useful when used in 
multiple threads? Am I missing the point completely?


More information about the Digitalmars-d-learn mailing list