ptupitsyn commented on code in PR #7921:
URL: https://github.com/apache/ignite-3/pull/7921#discussion_r3032329903
##########
modules/api/src/main/java/org/apache/ignite/lang/CancelHandleImpl.java:
##########
@@ -96,12 +101,39 @@ void addCancelAction(Runnable action, CompletableFuture<?>
fut) {
}
}
- boolean isCancelled() {
+ @Override
+ public boolean isCancelled() {
return cancelFut != null;
}
+ @Override
+ public AutoCloseable listen(Runnable callback) {
+ Objects.requireNonNull(callback, "callback");
+
+ if (cancelFut != null) {
+ callback.run();
+ return () -> { };
+ }
+
+ synchronized (mux) {
+ if (cancelFut == null) {
+ listeners.add(callback);
+ return () -> {
+ synchronized (mux) {
+ listeners.remove(callback);
+ }
+ };
+ }
+ }
+
+ callback.run();
+ return () -> { };
+ }
+
@SuppressWarnings("rawtypes")
void cancel() {
+ List<Runnable> listenersCopy;
Review Comment:
Valid concern I think.
--
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]