Low-Lock Singletons In D

Mehrdad wfunction at hotmail.com
Mon May 6 03:18:23 PDT 2013


On Monday, 6 May 2013 at 10:12:53 UTC, deadalnix wrote:
> On Monday, 6 May 2013 at 10:06:50 UTC, Mehrdad wrote:
>> On Monday, 6 May 2013 at 09:35:59 UTC, Dmitry Olshansky wrote:
>>> You have to read a field to know what to do next, and the 
>>> other processor may as well write to it.
>>
>>
>> That never happens, though. _static is only written to inside 
>> a lock, and the check is inside a lock, hence the other 
>> processor can't be writing to it when it's being read...
>>
>>
>> Maybe I misunderstood what you're saying?
>
> ON x86 you rarely see this kind of thing as the memory model is 
> strong. You can see some weird thing in rare cases, but as soon 
> as you leave x86 world, it isn't even worth trying.


Ah yeah, this entire thing was geared toward x86.

On a second thought, maybe it probably doesn't improve anything 
compared to the double-checked lock, since the branch prediction 
for 'if' is most likely faster than the branch prediction for a 
virtual call anyway. It was worth trying I guess...


More information about the Digitalmars-d mailing list