Looking for portable, simple and elegant replacement for Win32 InterlockedExchangePointer. Ideally using C++11 only but boost will do too.
The standard atomic types have an atomic exchange
function. So the Microsoftese
PVOID volatile target;
old_value = InterlockedExchangePointer(&target, new_value);
would become
std::atomic<T*> target;
old_value = target.exchange(new_value);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With