How can I implement ABA counter with c++11 CAS?
To atomically modify two things at once with a single atomic operation, you need to put them in adjacent memory, e.g. in a two-member struct. Then you can use std::atomic<my_struct> to get gcc to emit lock cmpxchg16b on x86-64, for example. You don’t need inline asm for this, and it’s worth a bit of C++ … Read more