public interface CancellationToken
Promise
. Cancellation tokens can be produced using
CancellationTokenSource
.CancellationTokenSource
,
Promise
Modifier and Type | Method and Description |
---|---|
boolean |
isCancellationRequested()
Returns whether cancellation has been requested.
|
CancellationTokenRegistration |
register(Action<? extends RuntimeException> observer)
Registers a function that is invoked when cancellation is requested.
|
CancellationTokenRegistration |
register(Action<? extends RuntimeException> observer,
boolean useScheduler)
Registers a function that is invoked when cancellation is requested.
|
void |
throwIfCancellationRequested()
Throws an exception in case
isCancellationRequested() evaluates to true. |
boolean isCancellationRequested()
void throwIfCancellationRequested()
isCancellationRequested()
evaluates to true.CancellationTokenRegistration register(Action<? extends RuntimeException> observer)
observer
- the action to invoke when cancellation is requested.CancellationTokenRegistration register(Action<? extends RuntimeException> observer, boolean useScheduler)
observer
- the action to invoke when cancellation is requested.useScheduler
- if set to true, the current AsyncScheduler is captured and used for
invoking the callback.