difference between x.atomicOp!"+="(1) and atomicFetchAdd(x, 1)?
mw
mingwu at gmail.com
Thu Nov 10 17:04:31 UTC 2022
Hi,
Anyone can help explain what is the difference between
x.atomicOp!"+="(1) and atomicFetchAdd(x, 1)?
From the doc, their return values are different
atomicOp
Performs the binary operation 'op' on val using 'mod' as the
modifier.
Returns:
The result of the operation.
atomicFetchAdd
Atomically adds mod to the value referenced by val and returns
the value val held previously. This operation is both lock-free
and atomic.
Returns:
The value held previously by val.
Apart from this, any other difference, esp in a multithreaded
program? Are they the same? Is atomicOp also lock-free?
Thanks.
More information about the Digitalmars-d-learn
mailing list