public abstract class ProposedTimestamp extends Object implements AutoCloseable
MonotonicClock.propose()
.
ProposedTimestamp implements AutoCloseable so that implementations can
release resources associated with obtaining certainty about time elapsing.
For example the constructing MonotonicClock may start network IO with peers
when creating the ProposedTimestamp, and close()
can ensure those
network resources are released in a timely fashion.
Constructor and Description |
---|
ProposedTimestamp() |
Modifier and Type | Method and Description |
---|---|
abstract void |
blockUntil(Duration maxWait)
Wait for this proposed timestamp to be certainly in the recent past.
|
static void |
blockUntil(Iterable<ProposedTimestamp> times,
Duration maxWait)
Wait for several timestamps.
|
void |
close() |
Date |
date()
Get time since epoch, with up to millisecond resolution.
|
Instant |
instant()
Get time since epoch, with up to microsecond resolution.
|
long |
micros()
Get microseconds since epoch;
read(MICROSECONDS ). |
long |
millis()
Get milliseconds since epoch;
read(MILLISECONDS ). |
abstract long |
read(TimeUnit unit)
Read the timestamp as
unit since the epoch. |
Timestamp |
timestamp()
Get time since epoch, with up to microsecond resolution.
|
String |
toString() |
public static void blockUntil(Iterable<ProposedTimestamp> times, Duration maxWait) throws TimeoutException, InterruptedException
times
- timestamps to wait on.maxWait
- how long to wait for the timestamps.InterruptedException
- current thread was interrupted before the waiting process
completed normally.TimeoutException
- the timeout was reached without the proposed timestamp become
certainly in the past.public abstract long read(TimeUnit unit)
unit
since the epoch.
The timestamp value for a specific ProposedTimestamp
object never
changes, and can be read before blockUntil(Duration)
.
unit
- what unit to return the timestamp in. The timestamp will be
rounded if the unit is bigger than the clock's granularity.unit
since the epoch.public abstract void blockUntil(Duration maxWait) throws InterruptedException, TimeoutException
This method forces the caller to wait up to timeout
for
this
to pass sufficiently into the past such that the creating
MonotonicClock
instance will not
create an earlier timestamp.
maxWait
- how long the implementation may block the caller.InterruptedException
- current thread was interrupted before the waiting process
completed normally.TimeoutException
- the timeout was reached without the proposed timestamp
becoming certainly in the past.public long millis()
read(MILLISECONDS
).read(MILLISECONDS
).public long micros()
read(MICROSECONDS
).read(MICROSECONDS
).public Instant instant()
public Timestamp timestamp()
public Date date()
public void close()
Release resources allocated by this timestamp.
close
in interface AutoCloseable
Copyright © 2017 Eclipse JGit Project. All rights reserved.