Class ReactiveSchedulerBatch<TKey, T>
Represents a queue of elements, which are processed in batches, automatically or on demand, with auto-flushing registered via a ReactiveScheduler<TKey>.
public abstract class ReactiveSchedulerBatch<TKey, T> : Batch<T>, IBatch<T>, IDisposable, IAsyncDisposable where TKey : notnull
Type Parameters
TKeyScheduler task's key type.
TElement type.
- Inheritance
-
Batch<T>ReactiveSchedulerBatch<TKey, T>
- Implements
-
IBatch<T>
- Inherited Members
Constructors
ReactiveSchedulerBatch(IReactiveScheduler<TKey>, TKey, Duration, BatchQueueOverflowStrategy, int, int, int)
Creates a new ReactiveSchedulerBatch<TKey, T> instance.
protected ReactiveSchedulerBatch(IReactiveScheduler<TKey> scheduler, TKey key, Duration autoFlushDelay, BatchQueueOverflowStrategy queueOverflowStrategy = BatchQueueOverflowStrategy.DiscardLast, int autoFlushCount = 1000, int queueSizeLimitHint = 100000000, int minInitialCapacity = 0)
Parameters
schedulerIReactiveScheduler<TKey>Scheduler in which to register auto-flush task.
keyTKeyIdentifier of the auto-flush task in the
scheduler.autoFlushDelayDurationSpecifies the delay with which auto-flush should be scheduled after first item was added to an empty batch.
queueOverflowStrategyBatchQueueOverflowStrategySpecifies the maximum number of enqueued elements that, when exceeded while adding new elements, will cause this batch to react according to its QueueOverflowStrategy. Equal to DiscardLast by default.
autoFlushCountintSpecifies the number of enqueued elements, which acts as a threshold that, when reached while adding new elements, will cause this batch to automatically Flush() itself. Equal to 1 000 by default.
queueSizeLimitHintintSpecifies the maximum number of enqueued elements that, when exceeded while adding new elements, will cause this batch to react according to its QueueOverflowStrategy. Equal to 100 000 000 by default.
minInitialCapacityintSpecifies minimum initial capacity of the internal queue. Equal to 0 by default.
Exceptions
- ArgumentOutOfRangeException
When
autoFlushDelayis less than or equal to Zero or whenautoFlushCountis less than 1.- InvalidOperationException
When auto-flush task could not be registered in the provided
scheduler, either because the scheduler is disposed or a task with the providedkeyalready exists.
Properties
AutoFlushDelay
Specifies the delay with which auto-flush should be scheduled after first item was added to an empty batch.
public Duration AutoFlushDelay { get; }
Property Value
Scheduler
Scheduler in which auto-flush task is registered.
public IReactiveScheduler<TKey> Scheduler { get; }
Property Value
- IReactiveScheduler<TKey>
SchedulerKey
Identifier of the auto-flush task in the Scheduler.
public TKey SchedulerKey { get; }
Property Value
- TKey
Methods
OnDisposed()
Allows to react to the batch being disposed.
protected override void OnDisposed()
Remarks
Exceptions thrown by this method will be completely ignored. The batch will not have any enqueued elements at the moment of invocation of this method.
OnEnqueued(QueueSlimMemory<T>, bool)
Allows to react to a non-empty range of elements being enqueued.
protected override void OnEnqueued(QueueSlimMemory<T> items, bool autoFlushing)
Parameters
itemsQueueSlimMemory<T>Range of enqueued elements.
autoFlushingboolSpecifies whether this batch will be automatically flushed due to the combination of its AutoFlushCount and new elements being added.
Remarks
Exceptions thrown by this method will be completely ignored.