mbien commented on code in PR #7030:
URL: https://github.com/apache/netbeans/pull/7030#discussion_r1484947404


##########
extide/gradle/src/org/netbeans/modules/gradle/execute/GradleDaemonExecutor.java:
##########
@@ -439,41 +441,70 @@ private static String gradleExecutable() {
         return Utilities.isWindows() ? "bin\\gradle.bat" : "bin/gradle"; 
//NOI18N
     }
 
-    public final ExecutorTask createTask(ExecutorTask process) {
+    // TODO one of the two methods can likely go from the API
+    // setTask is called first and signals the runnable to start
+    // the started runnable requires (!) the gradleTask so it can't be created 
in createTask
+    @Override
+    public void setTask(ExecutorTask task) {
         assert gradleTask == null;
-        gradleTask = new GradleTask(process);
+        gradleTask = new GradleTask(task);
+        super.setTask(task);
+    }
+
+    @Override
+    public final ExecutorTask createTask(ExecutorTask process) {
+        assert gradleTask != null;
+        assert task == process;
         return gradleTask;
     }
 
+    // task which can finish early, like a CompletableFuture
     private static final class GradleTask extends ExecutorTask {
-        private final ExecutorTask delegate;
-        private Integer result;
 
+        private final ExecutorTask delegate;
+        private volatile Integer result;
+        // is 0 when wrapper or delegate finished
+        private final CountDownLatch doneSignal = new CountDownLatch(1);
+        
         GradleTask(ExecutorTask delegate) {
             super(() -> {});
             this.delegate = delegate;
+            this.delegate.addTaskListener(t -> doneSignal.countDown());

Review Comment:
   >  I've found paths in GradleDaemonExecutor::run - the exception handlers, 
that do not call gradleTask.finish at all, so these all will reach this lambda 
and produce result 0 ?
   
   @sdedic this was the case before too, no?
   ```
               if (result != null) {
                   return result;
               }
               return this.delegate.result();
   ```
   this would have blocked on the delegate task and return the result. I am not 
100% sure what you mean by 0.
   



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

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to