dcapwell commented on code in PR #101:
URL: https://github.com/apache/cassandra-accord/pull/101#discussion_r1663165894


##########
accord-core/src/main/java/accord/topology/TopologyManager.java:
##########
@@ -371,17 +395,86 @@ private int indexOf(long epoch)
         }
     }
 
+    private static class FutureEpoch
+    {
+        private volatile AsyncResult.Settable<Void> future;
+        private long deadlineMillis;
+
+        public FutureEpoch(long deadlineMillis)
+        {
+            this.future = AsyncResults.settable();
+            this.deadlineMillis = deadlineMillis;
+        }
+
+        /*
+         * Notify any listeners that are waiting for the epoch that is has 
been a long time since
+         * we started waiting for the epoch. We may still eventually get the 
epoch so also create
+         * a new future so subsequent operations may have a chance at seeing 
the epoch if it ever appears.
+         *
+         * Subsequent waiters may get a timeout notification far sooner 
(WATCHDOG_INTERVAL_MILLISS)
+         * instead of EPOCH_INITIAL_TIMEOUT_MILLIS
+         */
+        @GuardedBy("TopologyManager.this")
+        public void timeOutCurrentListeners(long newDeadline, Agent agent)
+        {
+            deadlineMillis = newDeadline;
+            AsyncResult.Settable<Void> oldFuture = future;
+            if (oldFuture.isDone())
+                return;
+            future = AsyncResults.settable();
+            future.addCallback(agent);

Review Comment:
   looks like its set in `accord.topology.TopologyManager#onTopologyUpdate`, so 
both share the same lock; so this code is fine



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