valepakh commented on code in PR #7921:
URL: https://github.com/apache/ignite-3/pull/7921#discussion_r3032939321


##########
modules/api/src/main/java/org/apache/ignite/lang/CancellationToken.java:
##########
@@ -22,4 +22,24 @@
  * to terminate it.
  */
 public interface CancellationToken {
+    /**
+     * Flag indicating whether cancellation was requested or not.
+     *
+     * <p>This method will return {@code true} even if cancellation has not 
been completed yet.
+     *
+     * @return {@code true} when cancellation was requested.
+     */
+    boolean isCancelled();
+
+    /**
+     * Registers a callback to be executed when cancellation is requested. If 
cancellation has already been requested,
+     * the callback is executed immediately.
+     *
+     * <p>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.
+     *
+     * @param callback Callback to execute when cancellation is requested.
+     * @return A handle which can be used to stop listening for cancellation 
requests.
+     */
+    AutoCloseable listen(Runnable callback);

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to