News for hackers. Stuff that matters.
Re:You Can Do Any Kind of Atomic Read-Modify-Write Operation by yurymik on Thursday October 08, 2015 @03:20PM (#10355357)
Here's just to back up atomic_cheese's answer with some references:

Atomically, compares the contents of the memory pointed to by object or by this for equality with that in expected, and if true, replaces the contents of the memory pointed to by object or by this with that in desired, and if false, updates the contents of the memory in expected with the contents of the memory pointed to by object or by this.

http://open-std.org/JTC1/SC22/WG21/docs/papers/2011/n3242.pd...

Atomically compares the object representation of this with the object representation of expected, as if by std::memcmp, and if those are bitwise-equal, replaces the former with desired (performs read-modify-write operation). Otherwise, loads the actual value stored in this into expected (performs load operation). Copying is performed as if by std::memcpy.

http://en.cppreference.com/w/cpp/atomic/atomic/compare_excha...

There are no comments on this comment yet.