-
public class CancellationToken
Copyright 2017 Meniga Iceland Inc.
Propagates notification that operations should be canceled.
Create an instance of
{@code CancellationTokenSource}
and pass the token returned from{@code CancellationTokenSource#getToken()}
to the asynchronous operation(s). Call{@code CancellationTokenSource#cancel()}
to cancel the operations.A
{@code CancellationToken}
can only be cancelled once - it should not be passed to future operations once cancelled.
-
-
Constructor Summary
Constructors Constructor Description CancellationToken(CancellationTokenSource tokenSource)
-
Method Summary
Modifier and Type Method Description boolean
isCancellationRequested()
CancellationTokenRegistration
register(Runnable action)
Registers a runnable that will be called when this CancellationToken is canceled.If this token is already in the canceled state, the runnable will be run immediately and synchronously. void
throwIfCancellationRequested()
String
toString()
-
-
Constructor Detail
-
CancellationToken
CancellationToken(CancellationTokenSource tokenSource)
-
-
Method Detail
-
isCancellationRequested
boolean isCancellationRequested()
-
register
CancellationTokenRegistration register(Runnable action)
Registers a runnable that will be called when this CancellationToken is canceled.If this token is already in the canceled state, the runnable will be run immediately and synchronously.
- Parameters:
action
- the runnable to be run when the token is cancelled.
-
throwIfCancellationRequested
void throwIfCancellationRequested()
-
-
-
-