예제 #1
0
            public override void Enqueue(T1 item, int millisecondsTimeout)
            {
                using (ChoBarrier highBarrier = ChoBarrier.HighBarrier(_barrier))
                {
                    if (!highBarrier.Wait(millisecondsTimeout))
                    {
                        throw new ChoQueueTimeoutException();
                    }

                    _queue.Enqueue(item);
                }
            }
예제 #2
0
            public override T1 Dequeue(int millisecondsTimeout)
            {
                using (ChoBarrier lowBarrier = ChoBarrier.LowBarrier(_barrier))
                {
                    if (!lowBarrier.Wait(millisecondsTimeout))
                    {
                        throw new ChoQueueTimeoutException();
                    }

                    T1 item = _queue.Dequeue();
                    return(item);
                }
            }
예제 #3
0
 internal ChoBlockingQueue(ChoQueue <T1> queue, int size)
 {
     this._queue   = queue;
     this._size    = size;
     this._barrier = new ChoBarrier(0, size);
 }