public final class Timeout extends Object implements Comparable<Timeout>, 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_MINUTES
30 minutes
|
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,
TimeUnit unit)
Constructs a deadline using a given period of time
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Timeout that) |
boolean |
equals(Object o) |
long |
get(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)
|
void |
sleep(Deadline deadline)
Sleep for the duration of this timeout (or until the thread is interrupted, or until the provided deadline expires)
|
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() |
String |
toEnglishString() |
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 THIRTY_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,
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(TimeUnit toUnit)
toUnit - public 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 String toEnglishString()
public int compareTo(Timeout that)
compareTo in interface Comparable<Timeout>public void sleep()
public void sleep(Deadline deadline)
public org.joda.time.Duration toDuration()
public static Timeout max(Timeout... timeouts)
timeouts - a list of timeouts (nulls are ignored)IllegalArgumentException - if no non-null timeouts are presentedpublic static Timeout min(Timeout... timeouts)
timeouts - a list of timeouts (nulls are ignored)IllegalArgumentException - if no non-null timeouts are presentedCopyright © 2017. All rights reserved.