dcapwell commented on code in PR #101:
URL: https://github.com/apache/cassandra-accord/pull/101#discussion_r1664587814
##########
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:
is this really needed? In the callers found they are actually monotonic...
I assume C* is going to use `nanoTime`, so we don't have a `non-monotonic`
case; and if we do thats actually a bug in the test code...
--
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]