MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / ExchangePointer

Function ExchangePointer

Sources/nCine/Threading/Thread.cpp:54–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52
53 template<typename T>
54 DEATH_ALWAYS_INLINE T ExchangePointer(T volatile* destination, T value)
55 {
56#if defined(DEATH_TARGET_MSVC)
57# if !defined(DEATH_TARGET_32BIT)
58 return (T)_InterlockedExchangePointer((void* volatile*)destination, value);
59# else
60 return (T)_InterlockedExchange((long volatile*)(void* volatile*)destination, (long)(void*)value);
61# endif
62#else
63 T result = (T)__atomic_exchange_n((void* volatile*)destination, value, __ATOMIC_ACQ_REL);
64 InterlockedOperationBarrier();
65 return result;
66#endif
67 }
68
69 template<typename T>
70 DEATH_ALWAYS_INLINE T ExchangePointer(T volatile* destination, std::nullptr_t value)

Callers 1

DetachMethod · 0.85

Calls 1

Tested by

no test coverage detected