public void Depart ()
{
while (true) {
int x = var;
short c, v;
bool a;
Decode (x, out c, out a, out v);
if (Interlocked.CompareExchange (ref var, Encode ((short)(c - 1), false, v), x) == x) {
if (c >= 2)
return;
while (true) {
int i = state;
if (((short)(var >> 16)) != v)
return;
int newI = (i & 0x7FFFFFFF) + 1;
if (Interlocked.CompareExchange (ref state, newI, i) == i) {
return;
}
}
}
}
}