On 5/6/13 2:25 PM, Mehrdad wrote:
On Monday, 6 May 2013 at 13:33:54 UTC, Andrei Alexandrescu wrote:
It's well known. Needs a memory barrier on each access, so it's slower.


Hmm, are you saying I'm missing a memory barrier I should have written,
or are you saying I already have a memory barrier which I'm not seeing?


The only memory barrier I have is during initialization, and after that
only read operations occur.

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

Reply via email to