Pavel Tupitsyn created IGNITE-27856:
---------------------------------------
Summary: Extend CancellationToken API
Key: IGNITE-27856
URL: https://issues.apache.org/jira/browse/IGNITE-27856
Project: Ignite
Issue Type: Improvement
Components: compute ai3
Reporter: Pavel Tupitsyn
As a user, I want to get a callback when *CancellationToken* is cancelled. For
example, in my compute job (after IGNITE-27855), I want to reach to
cancellation quickly, release resources, stop scheduled tasks, etc.
Proposed API:
{code:java}
public interface CancellationToken {
/**
* Flag indicating whether cancellation was requested.
*
* @return {@code true} when cancellation was requested.
*/
boolean isCancelled();
/**
* Registers a callback to be executed when cancellation is requested.
*
* @param callback Callback to be executed when cancellation is requested.
* @return A handle which can be used to stop listening for cancellation
requests.
* It is important to close the handle when the callback is not needed
anymore to avoid memory leaks.
*/
AutoCloseable listen(Runnable callback);
}
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)