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 TypeMethodDescriptionvoid
cancel()
Request cancellation.static CancellationToken
create()
Create a new, uncancelled cancellation token.static CancellationToken
disabled()
Get a new cancellation token that cannot be cancelled.boolean
Returns 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 returnfalse
in a subsequent call.- Returns:
- whether cancellation has been requested
-
cancel
void cancel()Request cancellation.This will call subsequent calls to
isCancellationRequested()
to returntrue
.
-