ManualResetEvent handle;
internal AtomicBooleanValue disposed;
int used;
- long state;
+ int state;
public ManualResetEventSlim ()
: this (false, 10)
long UpdateStateWithOp (bool set)
{
- long oldValue, newValue;
+ int oldValue, newValue;
do {
oldValue = state;
- newValue = (long)(((oldValue >> 1) + 1) << 1) | (set ? 1u : 0u);
+ newValue = (int)(((oldValue >> 1) + 1) << 1) | (set ? 1 : 0);
} while (Interlocked.CompareExchange (ref state, newValue, oldValue) != oldValue);
return newValue;
}
* we have a mismatch between S and H at the end because the last operations done were
* S3/H1. We thus need to repeat H3 to get to the desired final state.
*/
- long currentState;
+ int currentState;
do {
currentState = state;
if (currentState != stamp && (stamp & 1) != (currentState & 1)) {
SpinWait wait = new SpinWait ();
while (!IsSet) {
- cancellationToken.ThrowIfCancellationRequested ();
-
if (wait.Count < spinCount) {
wait.SpinOnce ();
continue;
break;
}
+ cancellationToken.ThrowIfCancellationRequested ();
+
if (IsSet)
return true;