`shared Mutex`?

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Dec 28 06:43:11 PST 2014


On Sunday, 28 December 2014 at 09:24:31 UTC, Aiden wrote:
> 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?

Unfortunately, the current way to use shared is pretty much what 
you are doing now. It's probably one of the least understood and 
difficult to work with parts of the language.


More information about the Digitalmars-d-learn mailing list