/// <summary>
        /// Writes blocks of bytes to the stream from the input queue.
        /// </summary>
        public void Start(Stream stream, ISharedQueue <ByteBlock> inputQueue)
        {
            while (inputQueue.IsActive || inputQueue.Peek() != null)
            {
                if (CurrentBlockId != inputQueue.Peek()?.Id)
                {
                    continue;
                }

                var block = inputQueue.Pop();
                stream.Write(block.Data, 0, block.Data.Length);
                ++CurrentBlockId;
            }
        }
Example #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();
        }