Beispiel #1
0
        internal override bool Arrive()
        {
            bool arrivedAtParent = false;
            int  x;

            do
            {
                x = count;
                if (x == 0 && !arrivedAtParent)
                {
                    if (parent.Arrive())
                    {
                        arrivedAtParent = true;
                    }
                    else
                    {
                        return(false);
                    }
                }
            } while (Interlocked.CompareExchange(ref count, x + 1, x) != x);

            if (arrivedAtParent && x != 0)
            {
                parent.Depart();
            }

            return(true);
        }
Beispiel #2
0
        public CSnziNode Arrive()
        {
            while (true)
            {
                if (root.State != CSnziState.Open)
                {
                    return(null);
                }

                CSnziNode leaf = leafs[GetLeafIndex()];
                if (leaf.Arrive())
                {
                    return(leaf);
                }
                else
                {
                    return(null);
                }
            }
        }