Package org.apache.ignite.lang
Interface CancellationToken
public interface CancellationToken
Cancellation token is an object that is issued by
CancelHandle and can be used by an operation or a resource to observe a signal
to terminate it.-
Method Summary
Modifier and TypeMethodDescriptionaddListener(Runnable callback) Registers a callback to be executed when cancellation is requested.booleanFlag indicating whether cancellation was requested or not.
-
Method Details
-
isCancelled
boolean isCancelled()Flag indicating whether cancellation was requested or not.This method will return
trueeven if cancellation has not been completed yet.- Returns:
truewhen cancellation was requested.
-
addListener
Registers a callback to be executed when cancellation is requested. If cancellation has already been requested, the callback is executed immediately.The returned handle can be used to stop listening for cancellation requests. It is important to close the handle when the callback is no longer needed to avoid memory leaks.
- Parameters:
callback- Callback to execute when cancellation is requested.- Returns:
- A handle which can be used to stop listening for cancellation requests.
-