api / org.gradle.tooling / CancellationTokenSource

CancellationTokenSource

interface CancellationTokenSource

A CancellationTokenSource allows you to issue cancellation requests to one or more org.gradle.tooling.LongRunningOperation instances. To use a token source:

All implementations of this interface are required to be thread safe.

Since
2.1

Functions

cancel

abstract fun cancel(): Unit

Initiates cancel request. All operations that have been associated with this token will be cancelled.

It is assumed that the implementation will do 'best-effort' attempt to perform cancellation. This method returns immediately and if the cancellation is successful the cancelled operation will notify its org.gradle.tooling.ResultHandler#onFailure(GradleConnectionException) with a BuildCancelledException describing how it was cancelled.

token

abstract fun token(): CancellationToken

Returns a token associated with this CancellationTokenSource. Always returns the same instance.