Interface CancellationToken
Token that should be checked to determine whether an operation was requested
to be cancelled.
For example, this is used by the
Launcher and
TestEngine implementations to determine
whether the current test execution should be cancelled.
This interface is not intended to be implemented by clients.
- Since:
- 6.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Request cancellation.static CancellationTokencreate()Create a new, uncancelled cancellation token.static CancellationTokendisabled()Get a new cancellation token that cannot be cancelled.booleanReturns whether cancellation has been requested.
-
Method Details
-
create
Create a new, uncancelled cancellation token. -
disabled
Get a new cancellation token that cannot be cancelled.This is only useful for cases when a cancellation token is required but is not supported or irrelevant, for example, in tests.
-
isCancellationRequested
boolean isCancellationRequested()Returns whether cancellation has been requested.Once this method returns
true, it will never returnfalsein a subsequent call.- Returns:
- whether cancellation has been requested
-
cancel
void cancel()Request cancellation.This will call subsequent calls to
isCancellationRequested()to returntrue.
-