DIP 1024---Shared Atomics---Final Review
Petar
Petar
Tue Dec 10 15:14:26 UTC 2019
On Tuesday, 10 December 2019 at 11:30:36 UTC, Martin Tschierschke
wrote:
> On Sunday, 8 December 2019 at 16:25:21 UTC, Mike Parker wrote:
>> [...]
>
> Can somebody please give or point to simple examples on howto
> use core.atomic:
>
> shared int x; // ok, initialization to 0
> ++x; // error, read and write of shared x
>
> Looking into https://dlang.org/phobos/core_atomic.html was not
> so helpful for me.
shared int x, y;
x.atomicStore(41);
x.atomicOp!`+=`(1);
y.atomicStore = x.atomicLoad;
bool res = (&y).cas(42, 123);
assert(res);
assert(y.atomicLoad == 123);
More information about the Digitalmars-d
mailing list