Low-Lock Singletons In D

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue May 7 06:25:36 PDT 2013


On 5/7/13 2:50 AM, Mehrdad wrote:
> 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?

No. A tutorial on memory consistency models would be too long to insert 
here. I don't know of a good online resource, does anyone?

Andrei


More information about the Digitalmars-d mailing list