/// <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(); }
/// <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(); }