zrlw commented on code in PR #8954:
URL: https://github.com/apache/dubbo/pull/8954#discussion_r1437424159


##########
dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java:
##########
@@ -647,6 +679,26 @@ public void expire() {
                 return;
             }
 
+            // run timeout task at separate thread to avoid the worker thread 
blocking
+            try {
+                if (timer.taskExecutor == null) {
+                    // the global executor service should be gotten at each 
calling to avoid using invalid executor.
+                    
GlobalResourcesRepository.getGlobalExecutorService().execute(this);

Review Comment:
   > `taskExecutor` must not null ? Whether to consider that are must required ?
   
   you might see the outdated codes.
   ```
   private static final GlobalResourceInitializer<ExecutorService> 
DEFAULT_TIMER_TASK_EXECUTOR =
               new GlobalResourceInitializer<>(() ->
                   
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(),
                   new NamedThreadFactory("HashedWheelTimerTask", true)),
               executor -> executor.shutdown());
   ```
   the DEFAULT_TIMER_TASK_EXECUTOR  is only a GlobalResourceInitializer that 
the executor is only created when user decide to create the HashedWheelTimer by 
the default constructor instead of the new constructor which has added a new 
parameter taskExecutor:
   ```
       public HashedWheelTimer(
               ThreadFactory threadFactory,
               long tickDuration, TimeUnit unit, int ticksPerWheel,
               long maxPendingTimeouts, Executor taskExecutor) {
   ```



##########
dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java:
##########
@@ -647,6 +679,26 @@ public void expire() {
                 return;
             }
 
+            // run timeout task at separate thread to avoid the worker thread 
blocking
+            try {
+                if (timer.taskExecutor == null) {
+                    // the global executor service should be gotten at each 
calling to avoid using invalid executor.
+                    
GlobalResourcesRepository.getGlobalExecutorService().execute(this);

Review Comment:
   > `taskExecutor` must not null ? Whether to consider that are must required ?
   
   you might see the outdated PR codes.
   ```
   private static final GlobalResourceInitializer<ExecutorService> 
DEFAULT_TIMER_TASK_EXECUTOR =
               new GlobalResourceInitializer<>(() ->
                   
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(),
                   new NamedThreadFactory("HashedWheelTimerTask", true)),
               executor -> executor.shutdown());
   ```
   the DEFAULT_TIMER_TASK_EXECUTOR  is only a GlobalResourceInitializer that 
the executor is only created when user decide to create the HashedWheelTimer by 
the default constructor instead of the new constructor which has added a new 
parameter taskExecutor:
   ```
       public HashedWheelTimer(
               ThreadFactory threadFactory,
               long tickDuration, TimeUnit unit, int ticksPerWheel,
               long maxPendingTimeouts, Executor taskExecutor) {
   ```



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

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


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

Reply via email to