Semantics of shared
Jason House
jason.james.house at gmail.com
Thu May 14 10:52:37 PDT 2009
Walter Bright Wrote:
> Matt wrote:
>
> Shared data becomes unshared for the duration of a lock on it.
Is that a statement of fact? Or is it just speculation leading to the issues below? Even if this was changed to "scope unshared", that still is really hairy since scope is a storage class.
> The problem with this is:
>
> 1. determining that there are no other shared references into that data.
>
> 2. determining that the code operating on that data doesn't squirrel
> away a thread local reference to it.
>
> Currently, Bartosz is working on these problems. There is no solution
> yet other than using an (unsafe) cast and relying on the user not to
> screw it up.
His last blog implied he was further. I thought the recent shift to use TLS and shared inside dmd was because a design had been worked out. Without that, D hardly helps writing correct multi-threaded code :( It may be that I'm being overly pessimistic...
> >> Can you imagine two threads trying to sort the same array?
> > Not at the same time, but yes.
>
> That's why there's no way one would do this with simply shared data.
> Locks would be needed, too.
>
More information about the Digitalmars-d
mailing list