Table of Contents

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

Task

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

ValueTask

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

coalesceConsecutiveItems bool
valueProvider ValueProvider<TContainer, TValue>
dispatcher InAction<CompletedCoalescingQueueNode<TContainer, TValue>>
disposer InAction<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

coalesceConsecutiveItems bool
valueProvider ValueProvider<TContainer, TValue>
asyncDispatcher Func<CompletedCoalescingQueueNode<TContainer, TValue>, Task>
disposer InAction<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

maxToDispatch int

The 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

Event Type

Action