[
https://issues.apache.org/jira/browse/IGNITE-27856?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Pavel Tupitsyn updated IGNITE-27856:
------------------------------------
Description:
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}
Inspired by .NET CancellationToken
https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=net-10.0
was:
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}
> 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
> Priority: Major
> Labels: ignite-3
>
> 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}
> Inspired by .NET CancellationToken
> https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=net-10.0
--
This message was sent by Atlassian Jira
(v8.20.10#820010)