private UpdateStateWithOp ( bool set ) : long | ||
set | bool | |
return | long |
long UpdateStateWithOp(bool set)
{
long oldValue, newValue;
do {
oldValue = state;
newValue = (long)(((oldValue >> 1) + 1) << 1) | (set ? 1u : 0u);
} while (Interlocked.CompareExchange (ref state, newValue, oldValue) != oldValue);
return newValue;
}