/// <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> /// 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; } }
/// <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(); }
/// <summary> /// Initializes a new instance of the <see cref="QueueBasicConsumerDecorator"/> class. /// </summary> /// <param name="basicConsumer">The basic consumer.</param> /// <param name="sharedQueue">The shared queue.</param> internal QueueBasicConsumerDecorator(QueueingBasicConsumer basicConsumer, ISharedQueue sharedQueue) { _basicConsumer = basicConsumer; Queue = sharedQueue; }
/// <summary> /// Initializes a new instance of the <see cref="QueueBasicConsumerDecorator"/> class. /// </summary> /// <param name="basicConsumer">The basic consumer.</param> /// <param name="sharedQueue">The shared queue.</param> internal QueueBasicConsumerDecorator(QueueingBasicConsumer basicConsumer, ISharedQueue sharedQueue) { _basicConsumer = basicConsumer; Queue = sharedQueue; }