Class CancellationTokenMultiplexer
Represents cancellation token multiplexer.
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public sealed class CancellationTokenMultiplexer
Remarks
The multiplexer provides a pool of CancellationTokenSource to combine the cancellation tokens.
Properties
| Edit this page View SourceMaximumRetained
Gets or sets the maximum retained CancellationTokenSource instances.
Declaration
public int MaximumRetained { get; init; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceCombine(ReadOnlySpan<CancellationToken>)
Combines the multiple tokens.
Declaration
public CancellationTokenMultiplexer.Scope Combine(ReadOnlySpan<CancellationToken> tokens)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<CancellationToken> | tokens | The tokens to be combined. |
Returns
| Type | Description |
|---|---|
| CancellationTokenMultiplexer.Scope | The scope that contains a single multiplexed token. |
Combine(TimeSpan, ReadOnlySpan<CancellationToken>)
Combines the multiple tokens and the timeout.
Declaration
public CancellationTokenMultiplexer.Scope Combine(TimeSpan timeout, ReadOnlySpan<CancellationToken> tokens)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | timeout | The timeout that could trigger the cancellation. |
| ReadOnlySpan<CancellationToken> | tokens | The tokens to be combined. |
Returns
| Type | Description |
|---|---|
| CancellationTokenMultiplexer.Scope | The scope that represents the multiplexed token. |
Remarks
The cancellation triggered by the timeout can be detected by checking IsTimedOut.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
CombineAndSetTimeoutLater(ReadOnlySpan<CancellationToken>)
Combines the multiple tokens and sets the timeout later.
Declaration
public CancellationTokenMultiplexer.ScopeWithTimeout CombineAndSetTimeoutLater(ReadOnlySpan<CancellationToken> tokens)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<CancellationToken> | tokens | The tokens to be combined. |
Returns
| Type | Description |
|---|---|
| CancellationTokenMultiplexer.ScopeWithTimeout | The scope that represents the multiplexed token. |