Ejemplo n.º 1
0
        public override long waitFor(long sequence, Sequence cursor, Sequence[] dependents, ISequenceBarrier barrier)
        {
            long availableSequence;
            if ((availableSequence = cursor.get()) < sequence)
            {
                lock (_lock)
                {

                    try
                    {
                        ++numWaiters;
                        while ((availableSequence = cursor.get()) < sequence)
                        {
                            barrier.checkAlert();
                            Monitor.Wait(_lock);
                        }
                    }
                    finally
                    {
                        --numWaiters;
                    }
                }
            }

            if (0 != dependents.Length)
            {
                while ((availableSequence = Util.getMinimumSequence(dependents)) < sequence)
                {
                    barrier.checkAlert();
                }
            }

            return availableSequence;
        }