Table of Contents

Class AsyncMapBase.AsyncQueuedItem<TInput>

Namespace
SodaFlow.Async
Assembly
SodaFlow.Core.Async.dll

A value that a MapAsync pipeline tracks, from its admission until its promotion, its end, or its cancellation. It is also the one object that identifies the value in AsyncMapBase.AsyncToStart<TInput> and in OnCompleted(TState, AsyncQueuedItem<TInput>, AsyncCompletion, IReadOnlyList<AsyncTrackedItem<TInput>>). It is opaque. A strategy can keep one, usually in the state of its call, to promote it after this or to identify it again at its end, and can read its Value. A strategy cannot make one, because the constructor is internal and the class is sealed. Thus, each instance comes from an Admit(TState, AsyncQueuedItem<TInput>, IReadOnlyList<AsyncTrackedItem<TInput>>) call. A strategy always receives the same instance that it got before. Thus, ReferenceEquals, or ==, is sufficient to identify an admitted value in its state. An equal Id gives the same answer, and it is also correct across the different instances that the execution engine keeps for each admitted value. For that cause the SwitchLatest strategy in the library compares the Id.

[PublicAPI]
protected sealed class AsyncMapBase.AsyncQueuedItem<TInput>

Type Parameters

TInput
Inheritance
AsyncMapBase.AsyncQueuedItem<TInput>
Inherited Members
Extension Methods

Properties

Id

The identity of this item. The pipeline assigns it at the admission, and it is the same across the different AsyncMapBase.AsyncQueuedItem<TInput> instances that the execution engine keeps for one admitted value. One instance has the type for the strategy, and the other has the type for the public AsyncItem<TInput> view. An equal ID means the same tracked value.

Value

The value of this item at its admission.

Methods

Cancel()

Cancels this tracked item. It is the mechanism of a cancelAll stream and of a cancelMatching stream, and a strategy can use it for its own schedule. For example, SwitchLatest replaces its previous run with it. It operates on an item with the Queued status and on an item with the Running status. The pipeline does not start a Queued item at its turn, and a Running operation stops only if it monitors the CancellationToken that it got. In each condition the item ends as Canceled, thus OnCompleted(TState, AsyncQueuedItem<TInput>, AsyncCompletion, IReadOnlyList<AsyncTrackedItem<TInput>>) runs for it and can start the next operation. A call on an item that ended, on an item that a previous call canceled, or on an item at its end is safe. Those calls do nothing and are not errors, thus a strategy with a stale reference does not monitor the time when an item stops being cancellable.