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 theCancellationController and the CancellationSource are not.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns theCancellationControllerwhich can be used to signal cancellation to theCancellationTokenreturned by thegetToken()method.getToken()Returns theCancellationTokenwhich detects cancellation requests made through theCancellationControllerreturned by thegetController()method.
-
Method Details
-
getController
CancellationController getController()Returns theCancellationControllerwhich can be used to signal cancellation to theCancellationTokenreturned by thegetToken()method. That is, after thegetController().cancel()invocation, thegetToken().isCanceled()invocation will returntrue.- Returns:
- the
CancellationControllerwhich can be used to signal cancellation to theCancellationTokenreturned by thegetToken()method. This method never returnsnulland every invocation of this method will return the same object.
-
getToken
CancellationToken getToken()Returns theCancellationTokenwhich detects cancellation requests made through theCancellationControllerreturned by thegetController()method. That is, after thegetController().cancel()invocation, thegetToken().isCanceled()invocation will returntrue.- Returns:
- the
CancellationTokenwhich detects cancellation requests made through theCancellationControllerreturned by thegetController()method. This method never returnsnulland every invocation of this method will return the same object.
-