@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/262") public final class Deadline extends Object implements Comparable<Deadline>
| Modifier and Type | Method and Description |
|---|---|
static Deadline |
after(long duration,
TimeUnit units)
Create a deadline that will expire at the specified offset from the current system clock.
|
int |
compareTo(Deadline that) |
boolean |
isBefore(Deadline other)
Is
this deadline before another. |
boolean |
isExpired()
Has this deadline expired
|
Deadline |
minimum(Deadline other)
Return the minimum deadline of
this or an other deadline. |
Deadline |
offset(long offset,
TimeUnit units)
Create a new deadline that is offset from
this. |
ScheduledFuture<?> |
runOnExpiration(Runnable task,
ScheduledExecutorService scheduler)
Schedule a task to be run when the deadline expires.
|
long |
timeRemaining(TimeUnit unit)
How much time is remaining in the specified time unit.
|
String |
toString() |
public static Deadline after(long duration, TimeUnit units)
duration - A non-negative duration.units - The time unit for the duration.public boolean isExpired()
true if it has, otherwise false.public boolean isBefore(Deadline other)
this deadline before another.public Deadline minimum(Deadline other)
this or an other deadline.other - deadline to compare with this.public Deadline offset(long offset, TimeUnit units)
this.public long timeRemaining(TimeUnit unit)
TimeUnit.convert(long, java.util.concurrent.TimeUnit). If there is no time remaining, the returned duration is how
long ago the deadline expired.public ScheduledFuture<?> runOnExpiration(Runnable task, ScheduledExecutorService scheduler)
task - to run on expirationscheduler - used to execute the taskScheduledFuture which can be used to cancel execution of the taskpublic int compareTo(Deadline that)
compareTo in interface Comparable<Deadline>