Package org.eclipse.jgit.util.time
Class MonotonicSystemClock
- java.lang.Object
-
- org.eclipse.jgit.util.time.MonotonicSystemClock
-
- All Implemented Interfaces:
MonotonicClock
public class MonotonicSystemClock extends java.lang.Object implements MonotonicClock
AMonotonicClock
based onSystem.currentTimeMillis
.- Since:
- 4.6
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.concurrent.atomic.AtomicLong
before
-
Constructor Summary
Constructors Constructor Description MonotonicSystemClock()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static long
nowMicros()
ProposedTimestamp
propose()
Obtain a timestamp close to "now".
-
-
-
Method Detail
-
nowMicros
private static long nowMicros()
-
propose
public ProposedTimestamp propose()
Obtain a timestamp close to "now".Proposed times are close to "now", but may not yet be certainly in the past. This allows the calling thread to interleave other useful work while waiting for the clock instance to create an assurance it will never in the future propose a time earlier than the returned time.
A hypothetical implementation could read the local system clock (managed by NTP) and return that proposal, concurrently sending network messages to closely collaborating peers in the same cluster to also ensure their system clocks are ahead of this time. In such an implementation the
ProposedTimestamp.blockUntil(Duration)
method would wait for replies from the peers indicating their own system clocks have moved past the proposed time.- Specified by:
propose
in interfaceMonotonicClock
- Returns:
- a
ProposedTimestamp
object.
-
-