afs commented on code in PR #3603:
URL: https://github.com/apache/jena/pull/3603#discussion_r2550593561
##########
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:
I'm not sure `Thread.interruped()` is a good idea here.
It returns the current flag state and clears it - it is then lost. An
application using Jena as a library may have other uses for Thread interrupt.
Is this for a specific, known usage?
Maybe `Thread.currentThread().isInterrupted()` which is a read-only.
--
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]