System.Threading.Snzi.LeafNode.Arrive C# (CSharp) Method

Arrive() public method

public Arrive ( ) : void
return void
			public void Arrive ()
			{
				bool succ = false;
				int undoArr = 0;
				while (!succ) {
					int x = var;
					short c, v;
					Decode (x, out c, out v);
					
					if (c >= 1)
						if (Interlocked.CompareExchange (ref var, Encode ((short)(c + 1), v), x) == x)
							break;
					
					if (c == 0) {
						int temp = Encode (-1, (short)(v + 1));
						if (Interlocked.CompareExchange (ref var, temp, x) == x) {
							succ = true;
							c = -1;
							v += 1;
							x = temp;
						}
					}
					
					if (c == - 1) {
						parent.Arrive ();
						if (Interlocked.CompareExchange (ref var, Encode (1, v), x) != x)
							undoArr += 1;
					}
				}
				for (int i = 0; i < undoArr; i++)
					parent.Depart ();
			}