valepakh commented on code in PR #7921:
URL: https://github.com/apache/ignite-3/pull/7921#discussion_r3032289018
##########
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:
Not applicable — CancellationToken is not intended for external
implementation. The only implementation is CancellationTokenImpl
(package-private), and CancelHandleHelper.unwrapToken() enforces this by
throwing on any other type.
##########
modules/core/src/main/java/org/apache/ignite/lang/CancelHandleHelper.java:
##########
@@ -78,17 +78,6 @@ public static void addCancelAction(
addCancelAction(token, () -> completionFut.cancel(true),
completionFut);
}
Review Comment:
Not applicable — CancelHandleHelper is an internal utility class, not public
API. It accesses CancellationTokenImpl internals via casting and is not
intended for external consumption.
--
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]