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


##########
accord-core/src/main/java/accord/local/NodeTimeService.java:
##########
@@ -36,18 +37,53 @@ public interface NodeTimeService
     long now();
 
     /**
-     * Return the current time since the Unix epoch in the specified time 
unit. May still be simulated time and not
-     * real time.
+     * Return the current time since some arbitrary epoch in the specified 
time unit. May still be simulated time and not
+     * real time. The time returned by this will be monotonic.
      */
-    long unix(TimeUnit unit);
+    long elapsed(TimeUnit unit);
 
     Timestamp uniqueNow(Timestamp atLeast);
 
-    static ToLongFunction<TimeUnit> unixWrapper(TimeUnit sourceUnit, 
LongSupplier nowSupplier)
+    static ToLongFunction<TimeUnit> elapsedWrapperFromMonotonicSource(TimeUnit 
sourceUnit, LongSupplier monotonicNowSupplier)
+    {
+        return resultUnit ->  
resultUnit.convert(monotonicNowSupplier.getAsLong(), sourceUnit);
+    }
+
+    /**
+     * Allow time progression to be controlled using a potentially 
non-monotonic time source for testing with simulated
+     * time sources. This is not designed to be fast and real usage should be 
with a monotonic time source.
+     */
+    @VisibleForTesting
+    static ToLongFunction<TimeUnit> 
elapsedWrapperFromNonMonotonicSource(TimeUnit sourceUnit, LongSupplier 
nonMonotonicNowSupplier)

Review Comment:
   If we are concerned about non-monotonic time won't that be something that 
test code such as `BurnTest` exercises? I wanted the passage of monotonic time 
to match non-monotonic time, but just be monotonic and based off of a different 
epoch similar to how `nanoTime` works.
   
   We have code in `Node.uniqueNow` to ensure that it remains monotonic even 
when the time that is provided so we should exercise it if we aren't already.



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