Reading interlocked variables
问题 Assume: A. C++ under WIN32. B. A properly aligned volatile integer incremented and decremented using InterlockedIncrement() and InterlockedDecrement() . __declspec (align(8)) volatile LONG _ServerState = 0; If I want to simply read _ServerState, do I need to read the variable via an InterlockedXXX function? For instance, I have seen code such as: LONG x = InterlockedExchange(&_ServerState, _ServerState); and LONG x = InterlockedCompareExchange(&_ServerState, _ServerState, _ServerState); The