Class CoalescingQueue
- Namespace
- CounterpointCollective.Collections
- Assembly
- CounterpointCollective.CoalescingQueue.dll
A specialized coalescing queue that stores and dispatches instances of reference types. This concrete implementation is intended for scenarios where all values handled by the queue are reference types. For higher efficiency it is usually preferable to use the generic CoalescingQueue<TContainer> directly with a struct container type, as this avoids heap allocations and boxing.
public sealed class CoalescingQueue : ICoalescingQueue
- Inheritance
-
CoalescingQueue
- Implements
- Inherited Members
- Extension Methods
Properties
Completion
Initiates completion of the queue.
public Task Completion { get; }
Property Value
Remarks
After calling this method, the queue enters a completing state. Completion will transition to the completed state once all nodes that were already enqueued at the moment of calling Complete() have been fully processed.
Calling Enqueue() after calling Complete() will cause an exception.
Methods
AwaitQueueProcessed()
public ValueTask AwaitQueueProcessed()
Returns
Complete()
public void Complete()
CreateHandle<TValue>(bool, Action<TValue>)
public ICoalescingQueueHandle<CoalescingQueue.ObjectContainer, TValue> CreateHandle<TValue>(bool coalesceConsecutiveItems, Action<TValue> dispatcher) where TValue : class, new()
Parameters
Returns
Type Parameters
TValue
CreateHandle<TValue>(bool, Action<TValue>, IPool<TValue>)
public ICoalescingQueueHandle<CoalescingQueue.ObjectContainer, TValue> CreateHandle<TValue>(bool coalesceConsecutiveItems, Action<TValue> dispatcher, IPool<TValue> pool) where TValue : class
Parameters
Returns
Type Parameters
TValue
CreateHandle<TValue>(bool, Func<TValue, Task>)
public ICoalescingQueueHandle<CoalescingQueue.ObjectContainer, TValue> CreateHandle<TValue>(bool coalesceConsecutiveItems, Func<TValue, Task> asyncDispatcher) where TValue : class, new()
Parameters
Returns
Type Parameters
TValue
CreateHandle<TValue>(bool, Func<TValue, Task>, IPool<TValue>)
public ICoalescingQueueHandle<CoalescingQueue.ObjectContainer, TValue> CreateHandle<TValue>(bool coalesceConsecutiveItems, Func<TValue, Task> asyncDispatcher, IPool<TValue> pool) where TValue : class
Parameters
Returns
Type Parameters
TValue
ProcessPendingAsync(int)
Dequeues and processes pending completed nodes in the queue.
public ValueTask<bool> ProcessPendingAsync(int maxToDispatch = -1)
Parameters
maxToDispatchintThe maximum amount of items to dispatch. If -1, all pending items are dispatched.
Returns
- ValueTask<bool>
false when dispatch was already busy. Otherwise whether maxToDispatch was hit and there was more work.
StartProcessPending()
public void StartProcessPending()
Events
OnNodeCompleted
public event Action? OnNodeCompleted