lowka commented on code in PR #4615:
URL: https://github.com/apache/ignite-3/pull/4615#discussion_r1833914539


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/QueryCancel.java:
##########
@@ -22,13 +22,32 @@
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ScheduledExecutorService;
 import org.apache.ignite.internal.util.Cancellable;
+import org.apache.ignite.lang.CancelHandleHelper;
+import org.apache.ignite.lang.CancellationToken;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Holds query cancel state.
  */
 public class QueryCancel {
     private final CompletableFuture<Reason> state = new CompletableFuture<>();
 
+    /** Constructor. */
+    public QueryCancel() {
+        this(null);
+    }
+
+    /** Constructor. */
+    public QueryCancel(@Nullable CancellationToken cancellationToken) {
+        if (cancellationToken != null) {

Review Comment:
   PR no longer modifies `QueryCancel`



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/QueryCancel.java:
##########
@@ -22,13 +22,32 @@
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ScheduledExecutorService;
 import org.apache.ignite.internal.util.Cancellable;
+import org.apache.ignite.lang.CancelHandleHelper;
+import org.apache.ignite.lang.CancellationToken;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Holds query cancel state.
  */
 public class QueryCancel {
     private final CompletableFuture<Reason> state = new CompletableFuture<>();
 
+    /** Constructor. */
+    public QueryCancel() {
+        this(null);
+    }
+
+    /** Constructor. */
+    public QueryCancel(@Nullable CancellationToken cancellationToken) {
+        if (cancellationToken != null) {
+            // If token is provided, add this cancellation to its handle.
+            CompletableFuture<Void> fut = new CompletableFuture<>();
+            state.thenAccept(ignore -> fut.complete(null));
+
+            CancelHandleHelper.addCancelAction(cancellationToken, 
this::cancel, fut);

Review Comment:
   Fixed.



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to