C# Client Library
A C# Client Library for the AnalyzeRe REST API
|
Base class that consumes from a source asynchronously and produces a queue of some other resource to be consumed. More...
Public Member Functions | |
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. | |
Protected Member Functions | |
ProducerConsumerBuffer (int max_queue_size) | |
Construct a new ProducerConsumer that will read from the specified source and produce a Queue of buffered items to be consumed. | |
virtual void | Dispose (bool disposing) |
Cancel the producer thread and dispose of the queue. | |
bool | IsProducerFinished () |
Implementer indicates whether it can produce more items. | |
virtual void | OnDispose () |
Deriving classes' dispose actions. | |
virtual void | OnStart () |
Invoked before the asynchronous producer thread is started. | |
bool | TryProduceNext (out TProduced next) |
The method which asynchronously produces items. | |
Properties | |
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. | |
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. | |
Base class that consumes from a source asynchronously and produces a queue of some other resource to be consumed.
TProduced | The type of objects produced. |
Definition at line 15 of file ProducerConsumerBuffer.cs.
|
inlineprotected |
Construct a new ProducerConsumer that will read from the specified source and produce a Queue of buffered items to be consumed.
max_queue_size | The maximum number of buffers to create before blocking and waiting for existing bytes to be consumed. |
Definition at line 69 of file ProducerConsumerBuffer.cs.
|
inlinevirtual |
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.
|
inline |
Cancel the producer thread and dispose of the queue.
Definition at line 76 of file ProducerConsumerBuffer.cs.
|
inlineprotectedvirtual |
Cancel the producer thread and dispose of the queue.
disposing | Whether dispose is being called by the dispose method or the finalizer |
Definition at line 91 of file ProducerConsumerBuffer.cs.
|
abstractprotected |
Implementer indicates whether it can produce more items.
|
inlineprotectedvirtual |
Deriving classes' dispose actions.
Reimplemented in AnalyzeRe.LargeDataUpload.GZipBufferedBytesProducer.
Definition at line 102 of file ProducerConsumerBuffer.cs.
|
inlineprotectedvirtual |
Invoked before the asynchronous producer thread is started.
Reimplemented in AnalyzeRe.LargeDataUpload.AdaptiveBufferedBytesProducer, AnalyzeRe.LargeDataUpload.BinaryYELTConverter, AnalyzeRe.LargeDataUpload.BufferedBytesResizer, AnalyzeRe.LargeDataUpload.BufferedBytesToStringProducer, and AnalyzeRe.LargeDataUpload.GZipBufferedBytesProducer.
Definition at line 225 of file ProducerConsumerBuffer.cs.
|
inline |
Start the asynchronous producer.
cancellationToken | Cancellation token that will notify this producer if it is cancelled and halt the producer thread. |
InvalidOperationException | Producer is already running. |
Definition at line 110 of file ProducerConsumerBuffer.cs.
|
abstractprotected |
The method which asynchronously produces items.
next | The next item to add to the blocking collection. |
|
inline |
Attempts to remove an item from the produced list. May block if there is not yet an item ready, or return success:false.
success | Returns true if a valid item was returned. |
cancellation | A cancellation token which can be used to cancel this Take operation. |
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.
|
getprotected |
Can be used to cancel the buffering process.
Definition at line 53 of file ProducerConsumerBuffer.cs.
|
get |
Indicates whether a call to Take will ever return another item.
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.
|
getprotected |
Determines whether the consumer of this buffer is currently waiting for it to produce some data.
Definition at line 23 of file ProducerConsumerBuffer.cs.
|
get |
Indicates whether the producer is currently running.
Definition at line 26 of file ProducerConsumerBuffer.cs.
|
getprotected |
The collection of objects produced.
Definition at line 19 of file ProducerConsumerBuffer.cs.