Class CoalescingQueue<TContainer>
- Namespace
- CounterpointCollective.Collections
- Assembly
- CounterpointCollective.CoalescingQueue.dll
public sealed class CoalescingQueue<TContainer> : ICoalescingQueue where TContainer : struct
Type Parameters
TContainer
- Inheritance
-
CoalescingQueue<TContainer>
- Implements
- Inherited Members
- Extension Methods
Constructors
CoalescingQueue()
public CoalescingQueue()
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, ValueProvider<TContainer, TValue>, InAction<CompletedCoalescingQueueNode<TContainer, TValue>>, InAction<TContainer>?)
public ICoalescingQueueHandle<TContainer, TValue> CreateHandle<TValue>(bool coalesceConsecutiveItems, ValueProvider<TContainer, TValue> valueProvider, InAction<CompletedCoalescingQueueNode<TContainer, TValue>> dispatcher, InAction<TContainer>? disposer = null)
Parameters
coalesceConsecutiveItemsboolvalueProviderValueProvider<TContainer, TValue>dispatcherInAction<CompletedCoalescingQueueNode<TContainer, TValue>>disposerInAction<TContainer>
Returns
- ICoalescingQueueHandle<TContainer, TValue>
Type Parameters
TValue
CreateHandle<TValue>(bool, ValueProvider<TContainer, TValue>, Func<CompletedCoalescingQueueNode<TContainer, TValue>, Task>, InAction<TContainer>?)
public ICoalescingQueueHandle<TContainer, TValue> CreateHandle<TValue>(bool coalesceConsecutiveItems, ValueProvider<TContainer, TValue> valueProvider, Func<CompletedCoalescingQueueNode<TContainer, TValue>, Task> asyncDispatcher, InAction<TContainer>? disposer = null)
Parameters
coalesceConsecutiveItemsboolvalueProviderValueProvider<TContainer, TValue>asyncDispatcherFunc<CompletedCoalescingQueueNode<TContainer, TValue>, Task>disposerInAction<TContainer>
Returns
- ICoalescingQueueHandle<TContainer, TValue>
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