public final class Timeout extends java.lang.Object implements java.lang.Comparable<Timeout>, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
static Timeout |
FIVE_MINUTES
Five minutes
|
static Timeout |
MAX_VALUE
The maximum possible timeout
|
static Timeout |
ONE_MINUTE
One minute
|
static Timeout |
ONE_QUARTER_SECOND
0.25 seconds (250 milliseconds)
|
static Timeout |
ONE_SECOND
One second
|
static Timeout |
TEN_SECONDS
Ten seconds
|
static Timeout |
THIRTY_SECONDS
Thirty seconds
|
static Timeout |
ZERO
A zero-length timeout
|
| Constructor and Description |
|---|
Timeout(org.joda.time.Duration duration) |
Timeout(long milliseconds)
Constructs a deadline using a given period of time
|
Timeout(long period,
java.util.concurrent.TimeUnit unit)
Constructs a deadline using a given period of time
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Timeout that) |
boolean |
equals(java.lang.Object o) |
long |
get(java.util.concurrent.TimeUnit toUnit)
Get this timeout represented in a different unit
|
long |
getMilliseconds()
Get the number of milliseconds this timeout represents
|
int |
hashCode() |
static Timeout |
max(Timeout... timeouts)
Filter through a number of timeouts to find the one with the longest period
|
static Timeout |
min(Timeout... timeouts)
Filter through a number of timeouts to find the one with the shortest period
|
Timeout |
multiply(double by)
Create a new Timeout which is equal to this timeout multiplied by some value
The resulting Timeout will be in milliseconds to maximise precision. |
Timeout |
multiply(long by)
Create a new Timeout which is equal to this timeout multiplied by some value
|
void |
sleep()
Sleep for the duration of this timeout (or until the thread is interrupted)
|
Deadline |
start()
Create a new deadline which is the given period of time in the future
|
Deadline |
start(Deadline max)
Create a new deadline within a given maximum timeframe; this prevents
|
static Timeout |
sum(Timeout... timeouts)
Adds together all the supplied timeouts
|
org.joda.time.Duration |
toDuration() |
java.lang.String |
toString() |
public static final Timeout ZERO
public static final Timeout ONE_QUARTER_SECOND
public static final Timeout ONE_SECOND
public static final Timeout TEN_SECONDS
public static final Timeout THIRTY_SECONDS
public static final Timeout ONE_MINUTE
public static final Timeout FIVE_MINUTES
public static final Timeout MAX_VALUE
public Timeout(org.joda.time.Duration duration)
public Timeout(long milliseconds)
milliseconds - period in millisecondspublic Timeout(long period,
java.util.concurrent.TimeUnit unit)
period - the number of unitsunit - the unit of time being usedpublic Deadline start()
public Deadline start(Deadline max)
max - the maximum deadlinepublic long getMilliseconds()
public long get(java.util.concurrent.TimeUnit toUnit)
unit - public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic Timeout multiply(long by)
by - the amount to multiply the current timeout bypublic Timeout multiply(double by)
by - the amount to multiply the current timeout bypublic java.lang.String toString()
toString in class java.lang.Objectpublic int compareTo(Timeout that)
compareTo in interface java.lang.Comparable<Timeout>public void sleep()
public org.joda.time.Duration toDuration()
public static Timeout max(Timeout... timeouts)
timeouts - a list of timeouts (nulls are ignored)java.lang.IllegalArgumentException - if no non-null timeouts are presentedpublic static Timeout min(Timeout... timeouts)
timeouts - a list of timeouts (nulls are ignored)java.lang.IllegalArgumentException - if no non-null timeouts are presentedCopyright © 2014. All Rights Reserved.