public class CancellationTokens extends Object
Modifier and Type | Field and Description |
---|---|
static CancellationToken |
None
A cancellation token that will never be cancelled.
|
Constructor and Description |
---|
CancellationTokens() |
Modifier and Type | Method and Description |
---|---|
static CancellationToken |
any(CancellationToken... tokens)
Creates a cancellation token that goes into cancelled state if at least one of the
specified tokens goes into cancelled state.
|
static CancellationToken |
fromTimeout(int timeoutMs)
Creates a cancellation token that goes into cancelled state after the specified timeout
period elapsed.
|
static CancellationToken |
withTimeout(CancellationToken original,
int timeoutMs)
Creates a cancellation token that goes into cancelled state when either the specified timeout
period elapsed or the specified token goes into cancelled state, whatever happens first.
|
public static CancellationToken None
public static CancellationToken any(CancellationToken... tokens)
tokens
- the source cancellation tokens.public static CancellationToken withTimeout(CancellationToken original, int timeoutMs)
original
- the original token to observ.timeoutMs
- the timeout period in milliseconds.public static CancellationToken fromTimeout(int timeoutMs)
timeoutMs
- the timeout period in milliseconds.