예제 #1
0
        public void EnqueueForCompressing(byte[] buffer)
        {
            lock (locker)
            {
                if (isDead)
                {
                    throw new InvalidOperationException("Queue already stopped");
                }

                ByteBlock _block = new ByteBlock(blockId, buffer);
                queue.Enqueue(_block);
                blockId++;
                Monitor.PulseAll(locker);
            }
        }
예제 #2
0
        public void EnqueueForWriting(ByteBlock _block)
        {
            int id = _block.ID;

            lock (locker)
            {
                if (isDead)
                {
                    throw new InvalidOperationException("Queue already stopped");
                }

                while (id != blockId)
                {
                    Monitor.Wait(locker);
                }

                queue.Enqueue(_block);
                blockId++;
                Monitor.PulseAll(locker);
            }
        }