Fixing core.atomic

rm rymrg at memail.com
Wed Jun 2 14:08:32 UTC 2021


On 31/05/2021 23:33, Ola Fosheim Grøstad wrote:
> On Monday, 31 May 2021 at 16:34:35 UTC, Guillaume Piolat wrote:
>> On Monday, 31 May 2021 at 09:26:36 UTC, rm wrote:
>>>
>>> I don't consider this a problem. In this case you have a load and a 
>>> store. This is a non-atomic RMW. On the other hand, you do get 
>>> sequential consistency synchronization from this process.
>>
>> I prefer atomicLoad and atomicStore then, because it's explicit and 
>> it's useless to hide the fact it's atomic behind nice syntax.
> 
> Yes, how often do people use this anyway? I try to avoid concurrency 
> issues and have found that I tend to end up using compare-exchange when 
> I have to.
> 

It's useful if you want to implement known concurrency algorithms with 
SC semantics. Such as lamports lock (which requires SC).

http://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-1-of-2
http://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-2-of-2

It's there to nudge people away from using the weaker semantics and 
allow easy synchronization.


More information about the Digitalmars-d mailing list