zrlw commented on a change in pull request #8954:
URL: https://github.com/apache/dubbo/pull/8954#discussion_r729738081



##########
File path: 
dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java
##########
@@ -521,18 +559,18 @@ private long waitForNextTick() {
             long deadline = tickDuration * (tick + 1);
 
             for (; ; ) {
+                // the currentTime will be negative only if the application 
must keep running last more than 262 years.
                 final long currentTime = System.nanoTime() - startTime;
                 long sleepTimeMs = (deadline - currentTime + 999999) / 1000000;
 
                 if (sleepTimeMs <= 0) {
-                    if (currentTime == Long.MIN_VALUE) {
-                        return -Long.MAX_VALUE;
-                    } else {
-                        return currentTime;
-                    }
+                    return currentTime;

Review comment:
       Long.MIN_VALUE was once used as exit signal, the author add one only for 
distinguishing.
   the exit signal mechanism is not used anymore.
   you might draw a circle,Long.MIN_VALUE is always on the right of 
Long.MAX_VALUE. -Long.MAX_VALUE is alway on the right of Long.MIN_VALUE.
   the currenttime caculate the difference of two point on the time circle 
which perimeter has more than 262 years.

##########
File path: 
dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java
##########
@@ -521,18 +559,18 @@ private long waitForNextTick() {
             long deadline = tickDuration * (tick + 1);
 
             for (; ; ) {
+                // the currentTime will be negative only if the application 
must keep running last more than 262 years.
                 final long currentTime = System.nanoTime() - startTime;
                 long sleepTimeMs = (deadline - currentTime + 999999) / 1000000;
 
                 if (sleepTimeMs <= 0) {
-                    if (currentTime == Long.MIN_VALUE) {
-                        return -Long.MAX_VALUE;
-                    } else {
-                        return currentTime;
-                    }
+                    return currentTime;

Review comment:
       Long.MIN_VALUE was once used as exit signal, the author add one only for 
distinguishing.
   the exit signal mechanism is not used anymore.
   you might draw a circle,Long.MIN_VALUE is always on the right of 
Long.MAX_VALUE. -Long.MAX_VALUE is always on the right of Long.MIN_VALUE.
   the currenttime caculate the difference of two point on the time circle 
which perimeter has more than 262 years.

##########
File path: 
dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java
##########
@@ -521,18 +559,18 @@ private long waitForNextTick() {
             long deadline = tickDuration * (tick + 1);
 
             for (; ; ) {
+                // the currentTime will be negative only if the application 
must keep running last more than 262 years.
                 final long currentTime = System.nanoTime() - startTime;
                 long sleepTimeMs = (deadline - currentTime + 999999) / 1000000;
 
                 if (sleepTimeMs <= 0) {
-                    if (currentTime == Long.MIN_VALUE) {
-                        return -Long.MAX_VALUE;
-                    } else {
-                        return currentTime;
-                    }
+                    return currentTime;

Review comment:
       Long.MIN_VALUE is 1 smaller than -Long.MAX_VALUE
   




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

Reply via email to