belliottsmith commented on code in PR #121:
URL: https://github.com/apache/cassandra-accord/pull/121#discussion_r1764780971


##########
accord-core/src/test/java/accord/impl/basic/Cluster.java:
##########
@@ -219,18 +220,50 @@ public void processAll()
             processNext(next);
     }
 
+    boolean hasNonRecurring()
+    {
+        boolean hasNonRecurring = false;
+        for (Pending p : pending)
+        {
+            if (!(p instanceof RecurringPendingRunnable))
+                continue;
+            RecurringPendingRunnable r = (RecurringPendingRunnable) p;
+            if (r.requeue.hasNonRecurring())
+            {
+                hasNonRecurring = true;
+                break;
+            }
+        }
+
+        return hasNonRecurring;
+    }
+
     public boolean processPending()
     {
         checkFailures.run();
-        if (pending.size() == recurring)
+        // All remaining tasks are recurring
+        if (recurring > 0 && pending.size() == recurring && !hasNonRecurring())
             return false;
 
-        Object next = pending.poll();
+        Pending next = pending.poll();
         if (next == null)
             return false;
 
         processNext(next);
+
         checkFailures.run();
+
+        // If drain was requested, run until we have no non-recurring tasks 
are available
+        if (next instanceof RecurringPendingRunnable && 
((RecurringPendingRunnable) next).drainAfterRunning)

Review Comment:
   This drain task could itself submit some other post-drain task to e.g. 
re-enable messaging (and schedule the next journal replay task)



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