Is there a C ++ 11 replacement (or boost) for InterlockedExchangePointer?

We are looking for a portable, simple and elegant replacement for Win32 InterlockedExchangePointer. It is ideal to use only C ++ 11, but boost will do the same.

+5
source share
1 answer

standard atomic types have an atomic exchange function. So Microsoftese

 PVOID volatile target; old_value = InterlockedExchangePointer(&target, new_value); 

will become

 std::atomic<T*> target; old_value = target.exchange(new_value); 
+10
source

Source: https://habr.com/ru/post/1215981/


All Articles