afs commented on code in PR #3603:
URL: https://github.com/apache/jena/pull/3603#discussion_r2550158295


##########
jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/IterAbortable.java:
##########
@@ -31,49 +33,61 @@
  * when next touched (hasNext, next).
  */
 public class IterAbortable<T> extends IteratorWrapper<T> implements Abortable, 
IteratorCloseable<T> {
-    private volatile boolean abortFlag = false;
-    private boolean haveAborted = false;
+    private AtomicBoolean cancelSignal;
+    private volatile boolean abortedHere = false;
 
     public IterAbortable(Iterator<T> iterator) {
+        this(iterator, null);
+    }
+
+    protected IterAbortable(Iterator<T> iterator, AtomicBoolean cancelSignal) {
         super(iterator);
+        this.cancelSignal = cancelSignal;

Review Comment:
   ```suggestion
           this.cancelSignal = (cancelSignal != null) ? cancelSignal : new 
AtomicBoolean(false);
   ```



##########
jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/IterAbortable.java:
##########
@@ -31,49 +33,61 @@
  * when next touched (hasNext, next).
  */
 public class IterAbortable<T> extends IteratorWrapper<T> implements Abortable, 
IteratorCloseable<T> {
-    private volatile boolean abortFlag = false;
-    private boolean haveAborted = false;
+    private AtomicBoolean cancelSignal;
+    private volatile boolean abortedHere = false;

Review Comment:
   This can be removed - just use `cancelSignal`.
   
   ```suggestion
   ```



##########
jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/IterAbortable.java:
##########
@@ -31,49 +33,61 @@
  * when next touched (hasNext, next).
  */
 public class IterAbortable<T> extends IteratorWrapper<T> implements Abortable, 
IteratorCloseable<T> {
-    private volatile boolean abortFlag = false;
-    private boolean haveAborted = false;
+    private AtomicBoolean cancelSignal;
+    private volatile boolean abortedHere = false;
 
     public IterAbortable(Iterator<T> iterator) {
+        this(iterator, null);
+    }
+
+    protected IterAbortable(Iterator<T> iterator, AtomicBoolean cancelSignal) {
         super(iterator);
+        this.cancelSignal = cancelSignal;
+    }
+
+    public static <T> IterAbortable<T> wrap(Iterator<T> it, AtomicBoolean 
cancelSignal) {
+        return new IterAbortable<>(it, cancelSignal);
+    }
+
+    private boolean isAborted() {
+        return abortedHere || (cancelSignal != null && cancelSignal.get()) || 
Thread.interrupted();

Review Comment:
   ```suggestion
           return cancelSignal.get() || Thread.interrupted();
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to