I want to add a Phobos module with template mixins for common idioms.

Dmitry Olshansky dmitry.olsh at gmail.com
Mon May 20 09:40:24 PDT 2013


20-May-2013 19:28, Idan Arye пишет:
> On Monday, 20 May 2013 at 11:19:44 UTC, Diggory wrote:
>> Of course it's possible, for example the code may produce the expected
>> result if some invariant holds which does in fact hold if there was a
>> single thread running, but with multiple threads the invariant is
>> broken. Or more simply - the fact remains that you are writing on one
>> thread (correctly using synchronisation) and reading from another (not
>> using synchronisation) and synchronisation is required on both the
>> read and the write. The compiler/CPU is then free to reorder the reads
>> under the assumption that the value won't change, and this assumption
>> is clearly wrong.
>
> I do not assume that the compiler or the CPU will not change the order
> of reads in the unsynchronized thread - I showed that the result of
> `hasInstance()` is not affected by such reordering! `hasInstance()` has
> a single read to __gshared memory, and the only thing that can effect
> the result of that read is a write to that memory, which is done *once*
> in the synchronized thread. That means I should only care when the read
> in `hasInstance()` happens related to that write.
>

Long story short - re-read the discussion in the Low-lock thread again:
http://forum.dlang.org/thread/pelhvaxwjzhehdjtpsav@forum.dlang.org


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list