aweisberg commented on code in PR #7:
URL: https://github.com/apache/cassandra-accord/pull/7#discussion_r1014338886
##########
accord-core/src/main/java/accord/messages/Defer.java:
##########
@@ -0,0 +1,78 @@
+package accord.messages;
+
+import java.util.BitSet;
+import java.util.function.Function;
+
+import accord.local.*;
+import accord.local.Status.Known;
+import accord.primitives.TxnId;
+
+import static accord.local.PreLoadContext.contextFor;
+import static accord.messages.Defer.Ready.Expired;
+import static accord.messages.Defer.Ready.No;
+import static accord.messages.Defer.Ready.Yes;
+
+// TODO: use something more efficient? could probably assign each CommandStore
a unique ascending integer and use an int[]
+class Defer implements Listener
+{
+ public enum Ready { No, Yes, Expired }
+
+ final Function<Command, Ready> waitUntil;
+ final TxnRequest<?> request;
+ BitSet waitingOn = new BitSet(); // TODO: move to compressed integer hash
map to permit easier reclamation of ids
+ int waitingOnCount;
+ boolean isDone;
+
+ Defer(Known waitUntil, TxnRequest<?> request)
+ {
+ this(command -> {
+ int c = command.known().compareTo(waitUntil);
+ if (c < 0) return No;
+ if (c > 0) return Expired;
Review Comment:
I would add a comment "// The state change we were Deferring an action to
effect already occurred so no reason to take the action
--
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]