Interface CancellationSource


public interface CancellationSource
Defines an interface for linked CancellationController and CancellationToken objects. These two objects returned by the CancellationSource are linked in a way, that requesting cancellation through the CancellationController will cause the CancellationToken to move to a canceled state.

The two objects can be returned by the getController and the getToken methods.

Thread safety

Methods of this interface are required to be safely accessed by multiple threads concurrently.

Synchronization transparency

Methods of this interface are required to be synchronization transparent but note that the methods of the CancellationController and the CancellationSource are not.
See Also:
  • Method Details

    • getController

      CancellationController getController()
      Returns the CancellationController which can be used to signal cancellation to the CancellationToken returned by the getToken() method. That is, after the getController().cancel() invocation, the getToken().isCanceled() invocation will return true.
      Returns:
      the CancellationController which can be used to signal cancellation to the CancellationToken returned by the getToken() method. This method never returns null and every invocation of this method will return the same object.
    • getToken

      CancellationToken getToken()
      Returns the CancellationToken which detects cancellation requests made through the CancellationController returned by the getController() method. That is, after the getController().cancel() invocation, the getToken().isCanceled() invocation will return true.
      Returns:
      the CancellationToken which detects cancellation requests made through the CancellationController returned by the getController() method. This method never returns null and every invocation of this method will return the same object.