-
public class ForwardingTimeout extends Timeout
A Timeout which forwards calls to another. Useful for subclassing.
-
-
Constructor Summary
Constructors Constructor Description ForwardingTimeout(Timeout delegate)
-
Method Summary
Modifier and Type Method Description final ForwardingTimeoutsetDelegate(Timeout delegate)final Timeoutdelegate()Timeout instance to which this instance is currently delegating. Timeouttimeout(long timeout, TimeUnit unit)Wait at most {@code timeout}time before aborting an operation.longtimeoutNanos()Returns the timeout in nanoseconds, or {@code 0}for no timeout.booleanhasDeadline()Returns true if a deadline is enabled. longdeadlineNanoTime()Returns the nano time when the deadline willbe reached. TimeoutdeadlineNanoTime(long deadlineNanoTime)Sets the nano time when the deadline will bereached. TimeoutclearTimeout()Clears the timeout. TimeoutclearDeadline()Clears the deadline. voidthrowIfReached()Throws an InterruptedIOException if the deadline has been reached or if the currentthread has been interrupted. -
-
Constructor Detail
-
ForwardingTimeout
ForwardingTimeout(Timeout delegate)
-
-
Method Detail
-
setDelegate
final ForwardingTimeout setDelegate(Timeout delegate)
-
timeout
Timeout timeout(long timeout, TimeUnit unit)
Wait at most
{@code timeout}time before aborting an operation. Using aper-operation timeout means that as long as forward progress is being made,no sequence of operations will fail.If
{@code timeout == 0}, operations will run indefinitely. (Operatingsystem timeouts may still apply.)
-
timeoutNanos
long timeoutNanos()
Returns the timeout in nanoseconds, or
{@code 0}for no timeout.
-
hasDeadline
boolean hasDeadline()
Returns true if a deadline is enabled.
-
deadlineNanoTime
long deadlineNanoTime()
Returns the nano time when the deadline willbe reached.
-
deadlineNanoTime
Timeout deadlineNanoTime(long deadlineNanoTime)
Sets the nano time when the deadline will bereached. All operations must complete before this time. Use a deadline toset a maximum bound on the time spent on a sequence of operations.
-
clearTimeout
Timeout clearTimeout()
Clears the timeout. Operating system timeouts may still apply.
-
clearDeadline
Timeout clearDeadline()
Clears the deadline.
-
throwIfReached
void throwIfReached()
Throws an InterruptedIOException if the deadline has been reached or if the currentthread has been interrupted. This method doesn't detect timeouts; that should be implemented toasynchronously abort an in-progress operation.
-
-
-
-