public class CountdownTimer
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
Duration |
getDurationElapsed()
return how long the timer has been running (longer than limit if
isExpired() ) |
Duration |
getDurationRemaining()
returns how much time is left (negative if
isExpired() ) |
Duration |
getLimit()
how much total time this timer should run for
|
com.google.common.base.Stopwatch |
getStopwatch()
returns underlying stopwatch, which caller can inspect for more details or modify
|
boolean |
isExpired()
true iff the timer has been running for the duration specified at creation time
|
boolean |
isRunning()
true iff timer is running (even if it is expired)
|
static CountdownTimer |
newInstancePaused(Duration duration) |
static CountdownTimer |
newInstanceStarted(Duration duration) |
CountdownTimer |
pause()
pauses the timer, if running; no-op if not running
|
CountdownTimer |
start()
starts the timer, either initially or if
pause() d; no-op if already running |
void |
waitForExpiry()
block (on this object) until completed
|
void |
waitForExpiryUnchecked()
as
waitForExpiry() but catches and wraps InterruptedException as unchecked RuntimeInterruptedExcedption |
boolean |
waitOnForExpiry(java.lang.Object waitTarget)
block on the given argument until the timer is completed or the object receives a notified;
callers must be synchronized on the waitTarget
|
boolean |
waitOnForExpiryUnchecked(java.lang.Object waitTarget)
as
waitOnForExpiry(Object) but catches and wraps InterruptedException as unchecked RuntimeInterruptedExcedption |
public CountdownTimer start()
pause()
d; no-op if already runningpublic CountdownTimer pause()
public com.google.common.base.Stopwatch getStopwatch()
public Duration getLimit()
public Duration getDurationElapsed()
isExpired()
)public Duration getDurationRemaining()
isExpired()
)public boolean isExpired()
public boolean isRunning()
public static CountdownTimer newInstanceStarted(Duration duration)
public static CountdownTimer newInstancePaused(Duration duration)
public void waitForExpiry() throws java.lang.InterruptedException
java.lang.InterruptedException
public void waitForExpiryUnchecked()
waitForExpiry()
but catches and wraps InterruptedException as unchecked RuntimeInterruptedExcedptionpublic boolean waitOnForExpiry(java.lang.Object waitTarget) throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean waitOnForExpiryUnchecked(java.lang.Object waitTarget)
waitOnForExpiry(Object)
but catches and wraps InterruptedException as unchecked RuntimeInterruptedExcedption