, . . (, InterlockedCompareExchange Windows), , - . - , . , , .
The code below uses int, as Kate pointed out, you can use union to be able to get struct values as int.
int oldValue, newValue;
do
{
oldValue = myRef;
newValue = oldValue & ~AGE_MASK;
} while (InterlockedCompareExchange(&myRef, newValue, oldValue) != oldValue);
source
share