Exemplo n.º 1
0
        /// <summary>
        /// Breaks byte sequence into blocks and puts them in the output queue.
        /// </summary>
        public void Start(Stream stream, ISharedQueue <ByteBlock> outputQueue)
        {
            do
            {
                outputQueue.Push(new ByteBlock
                {
                    Id   = CurrentBlockId++,
                    Data = GetNextBlockData(stream),
                });
            } while (stream.HasNextByte());

            outputQueue.StopWrite();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Compresses/decompresses blocks from the input queue and then puts them in the output queue.
        /// </summary>
        public void Start(ISharedQueue <ByteBlock> inputQueue, ISharedQueue <ByteBlock> outputQueue)
        {
            while (inputQueue.IsActive || inputQueue.Peek() != null)
            {
                var block = inputQueue.Pop();
                if (block == null)
                {
                    continue;
                }

                block.Data = _compressionFunc(block.Data);
                outputQueue.Push(block);
            }
            outputQueue.StopWrite();
        }