Low-Lock Singletons In D
Mehrdad
wfunction at hotmail.com
Mon May 6 23:50:15 PDT 2013
On Monday, 6 May 2013 at 18:46:56 UTC, Andrei Alexandrescu wrote:
> Any concurrent operation (in this case read from one thread and
> write from another) requires a handshake between threads, most
> often in the form of an release write coupled with an acquire
> read. Whenever the handshake is absent but concurrent
> operations on shared memory do occur, the code is broken. The
> beauty of the TLS-based pattern is that in the steady state
> there's no need for a shared read and handshake.
>
> Andrei
Hmm, are you referring to the same lack of a barrier that the
others are also referring to?
As far as I can see, there shouldn't be a need for any other
handshake in this example.
As long as the object is fully initialized before _static is
written to (easy enough with just a memory barrier), there is no
penalty for subsequent reads whatsoever.
Right?
More information about the Digitalmars-d
mailing list