ptupitsyn commented on code in PR #4261:
URL: https://github.com/apache/ignite-3/pull/4261#discussion_r1730890823


##########
modules/client/src/main/java/org/apache/ignite/internal/client/TcpClientChannel.java:
##########
@@ -782,4 +803,120 @@ private class HeartbeatTask extends TimerTask {
             }
         }
     }
+
+    /**
+     * Timeout object worker.
+     */
+    private static class TimeoutWorker extends IgniteWorker {
+        /** Worker sleep interval. */
+        private final long sleepInterval = 
getLong("IGNITE_TIMEOUT_WORKER_SLEEP_INTERVAL", 500);
+
+        /** Active operation. */
+        public final ConcurrentMap<Long, TimeoutObject> requestsMap;
+
+        /**
+         * Constructor.
+         *
+         * @param log Logger.
+         * @param igniteInstanceName Name of the Ignite instance this runnable 
is used in.
+         * @param name Worker name. Note that in general thread name and 
worker (runnable) name are two different things. The same
+         *         worker can be executed by multiple threads and therefore 
for logging and debugging purposes we separate the two.
+         * @param requestsMap Active operations.
+         */
+        public TimeoutWorker(
+                IgniteLogger log,
+                String igniteInstanceName,
+                String name,
+                ConcurrentMap<Long, TimeoutObject> requestsMap
+        ) {
+            super(log, igniteInstanceName, name, null);
+
+            this.requestsMap = requestsMap;
+        }
+
+        @Override
+        protected void body() {
+            try {
+                TimeoutObject timeoutObject;
+
+                while (!isCancelled()) {
+                    long now = coarseCurrentTimeMillis();
+
+                    for (Entry<Long, TimeoutObject> entry : new 
HashMap<>(requestsMap).entrySet()) {

Review Comment:
   We iterate over the map to copy it anyway, it can't be faster than just 
iterating. Something must be wrong with the benchmark. 



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

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

Reply via email to