13 private const int MaxQueueSize = 3;
17 private const int BufferScalingFactor = 4;
19 #region Public Properties
34 #endregion Public Properties
36 #region Private Properties
38 private int _currentBufferSize;
39 #endregion Private Properties
52 int? max_buffer_length =
null)
58 #endregion Constructor
60 #region Private Methods
87 while (_currentBufferSize >
MinimumBufferLength && _currentBufferSize >= buffer.LengthFilled)
88 _currentBufferSize = Math.Max(_currentBufferSize / BufferScalingFactor,
MinimumBufferLength);
95 _currentBufferSize = Math.Min(_currentBufferSize * BufferScalingFactor,
MaximumBufferLength);
101 #endregion Private Methods
Produces BufferedByte objects of a variable size depending on whether the consumer of this buffer is ...
int MaximumBufferLength
The max length of the each byte array to generate. (Default 32 MiB)
bool TryProduceNext(out BufferedBytes next, int buffer_size)
The method which asynchronously produces items.
override bool TryProduceNext(out BufferedBytes buffer)
Attempts to read from the stream.
AdaptiveBufferedBytesProducer(int? min_buffer_length=null, int? max_buffer_length=null)
Construct a new AdaptiveBufferedBytesProducer which will prepare increasingly large buffers of bytes ...
int MinimumBufferLength
The minimum length of the byte array to generate when the consumer of this buffer is currently waitin...
long TotalBytesRead
The total number of bytes that have been buffered since start.
override void OnStart()
Ensure the FirstBufferLength doesn't exceed the set buffer length.
Base class that consumes from a source asynchronously and produces a queue of some other resource to ...
bool IsConsumerWaiting
Determines whether the consumer of this buffer is currently waiting for it to produce some data.
BlockingCollection< TProduced > Produced
The collection of objects produced.
The structure containing an array of bytes and integer indicating the number of bytes in the array th...