Converts buffered bytes to strings.
More...
|
| BufferedBytesToStringProducer (IProducerConsumerBuffer< BufferedBytes > source, Encoding encoding=null, int max_queue_size=3) |
| Construct a producer of strings from buffered bytes.
|
|
virtual void | Cancel () |
| Stop the producer from reading any more bytes. Warning: This will leave the stream in its current position and any bytes that haven't been inserted into the buffer are lost.
|
|
void | Dispose () |
| Cancel the producer thread and dispose of the queue.
|
|
void | Start (CancellationToken? cancellationToken=null) |
| Start the asynchronous producer.
|
|
TProduced | TryTake (out bool success, CancellationToken? cancellation) |
| Attempts to remove an item from the produced list. May block if there is not yet an item ready, or return success:false.
|
|
|
static readonly Encoding | DEFAULT_ENCODING = Encoding.UTF8 |
| The default encoding used if none is supplied at construction.
|
|
|
virtual void | Dispose (bool disposing) |
| Cancel the producer thread and dispose of the queue.
|
|
override bool | IsProducerFinished () |
| Indicates whether it can produce more items.
|
|
virtual void | OnDispose () |
| Deriving classes' dispose actions.
|
|
override void | OnStart () |
| Invoked before the producer thread is started.
|
|
override bool | TryProduceNext (out StringWithByteCount next) |
| Encode the next string.
|
|
bool | TryProduceNext (out TProduced next) |
| The method which asynchronously produces items.
|
|
|
CancellationTokenSource | Cancellation [get] |
| Can be used to cancel the buffering process.
|
|
bool | CanTake [get] |
| Indicates whether a call to Take will ever return another item.
|
|
Encoding | Encoding [get] |
| The encoding to use when producing the strings.
|
|
bool | IsConsumerWaiting [get] |
| Determines whether the consumer of this buffer is currently waiting for it to produce some data.
|
|
bool | IsRunning [get] |
| Indicates whether the producer is currently running.
|
|
BlockingCollection< TProduced > | Produced [get] |
| The collection of objects produced.
|
|
Converts buffered bytes to strings.
Definition at line 6 of file BufferedBytesToStringProducer.cs.
◆ AnalyzeRe::LargeDataUpload::BufferedBytesToStringProducer::StringWithByteCount
struct AnalyzeRe::LargeDataUpload::BufferedBytesToStringProducer::StringWithByteCount |
A tuple containing a string and its UTF8 bytes count.
Definition at line 16 of file BufferedBytesToStringProducer.cs.
Class Members |
int |
ByteLength |
The UTF8-Encoded byte length of the string. |
string |
String |
The value of the string. |
◆ BufferedBytesToStringProducer()
Construct a producer of strings from buffered bytes.
- Parameters
-
source | The source collection from which buffered bytes can be retrieved. |
encoding | The encoding to use when producing the strings. |
max_queue_size | The maximum number of strings to prepare in advance. |
Definition at line 33 of file BufferedBytesToStringProducer.cs.
◆ Cancel()
Stop the producer from reading any more bytes. Warning: This will leave the stream in its current position and any bytes that haven't been inserted into the buffer are lost.
Definition at line 172 of file ProducerConsumerBuffer.cs.
◆ Dispose() [1/2]
◆ Dispose() [2/2]
|
inlineprotectedvirtualinherited |
Cancel the producer thread and dispose of the queue.
- Parameters
-
disposing | Whether dispose is being called by the dispose method or the finalizer |
Definition at line 91 of file ProducerConsumerBuffer.cs.
◆ IsProducerFinished()
override bool AnalyzeRe.LargeDataUpload.BufferedBytesToStringProducer.IsProducerFinished |
( |
| ) |
|
|
protected |
Indicates whether it can produce more items.
- Returns
- True if it is finished producing items.
◆ OnDispose()
|
inlineprotectedvirtualinherited |
◆ OnStart()
override void AnalyzeRe.LargeDataUpload.BufferedBytesToStringProducer.OnStart |
( |
| ) |
|
|
inlineprotectedvirtual |
◆ Start()
Start the asynchronous producer.
- Parameters
-
cancellationToken | Cancellation token that will notify this producer if it is cancelled and halt the producer thread. |
- Exceptions
-
InvalidOperationException | Producer is already running. |
Definition at line 110 of file ProducerConsumerBuffer.cs.
◆ TryProduceNext() [1/2]
override bool AnalyzeRe.LargeDataUpload.BufferedBytesToStringProducer.TryProduceNext |
( |
out StringWithByteCount |
next | ) |
|
|
inlineprotected |
Encode the next string.
- Parameters
-
next | The next string to add to the queue. |
- Returns
- True if an item was successfully produced.
Definition at line 58 of file BufferedBytesToStringProducer.cs.
◆ TryProduceNext() [2/2]
|
abstractprotectedinherited |
The method which asynchronously produces items.
- Parameters
-
next | The next item to add to the blocking collection. |
- Returns
- True if an item was successfully produced.
◆ TryTake()
Attempts to remove an item from the produced list. May block if there is not yet an item ready, or return success:false.
- Parameters
-
success | Returns true if a valid item was returned. |
cancellation | A cancellation token which can be used to cancel this Take operation. |
- Returns
- The item removed from the list.
- Exceptions
-
BufferProducerException | If the producer thread raised an exception. |
InvalidOperationException | The producer thread is not currently running, either because the Start method has not been called, or because the Cancel method has been called. |
Definition at line 138 of file ProducerConsumerBuffer.cs.
◆ DEFAULT_ENCODING
readonly Encoding AnalyzeRe.LargeDataUpload.BufferedBytesToStringProducer.DEFAULT_ENCODING = Encoding.UTF8 |
|
static |
◆ Cancellation
◆ CanTake
Indicates whether a call to Take will ever return another item.
- Exceptions
-
BufferProducerException | If the producer thread raised an exception. |
HACK: Need some way of surfacing asynchronous errors without consumers assuming we're done, so raise any asynchronous exception here. TODO: Revisit Implementation such that BufferProducerException is discovered elsewhere CanTake can simply be made to return false if an exception occurred.
Definition at line 36 of file ProducerConsumerBuffer.cs.
◆ Encoding
Encoding AnalyzeRe.LargeDataUpload.BufferedBytesToStringProducer.Encoding |
|
get |
◆ IsConsumerWaiting
Determines whether the consumer of this buffer is currently waiting for it to produce some data.
Definition at line 23 of file ProducerConsumerBuffer.cs.
◆ IsRunning
◆ Produced
The documentation for this class was generated from the following file: