You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "icodening (via GitHub)" <gi...@apache.org> on 2023/04/10 11:26:00 UTC

[GitHub] [dubbo] icodening commented on a diff in pull request #11965: optimize ThreadlessExecutor

icodening commented on code in PR #11965:
URL: https://github.com/apache/dubbo/pull/11965#discussion_r1152760820


##########
dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/ThreadlessExecutor.java:
##########
@@ -56,60 +58,37 @@ public void setWaitingFuture(CompletableFuture<?> waitingFuture) {
         this.waitingFuture = waitingFuture;
     }

Review Comment:
   can be removed?



##########
dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/ThreadlessExecutor.java:
##########
@@ -38,78 +39,39 @@
 public class ThreadlessExecutor extends AbstractExecutorService {
     private static final Logger logger = LoggerFactory.getLogger(ThreadlessExecutor.class.getName());
 
-    private final BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
+    private static final Object SHUTDOWN = new Object();
 
-    private CompletableFuture<?> waitingFuture;
+    private final Queue<Runnable> queue = new ConcurrentLinkedQueue<>();
 
-    private boolean finished = false;
-
-    private volatile boolean waiting = true;
-
-    private final Object lock = new Object();
-
-    public CompletableFuture<?> getWaitingFuture() {
-        return waitingFuture;
-    }
-
-    public void setWaitingFuture(CompletableFuture<?> waitingFuture) {
-        this.waitingFuture = waitingFuture;
-    }
-
-    private boolean isFinished() {
-        return finished;
-    }
-
-    private void setFinished(boolean finished) {
-        this.finished = finished;
-    }
-
-    public boolean isWaiting() {
-        return waiting;
-    }
-
-    private void setWaiting(boolean waiting) {
-        this.waiting = waiting;
-    }
+    private volatile Object waiter;

Review Comment:
   Only need to be visible to other threads



-- 
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-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org