public class AsyncTimeout extends Timeout
Subclasses should override timedOut() to take action when a timeout occurs. This method
 will be invoked by the shared watchdog thread so it should not do any long-running operations.
 Otherwise we risk starving other timeouts from being triggered.
 
Use sink(okio.Sink) and source(okio.Source) to apply this timeout to a stream. The returned value
 will apply the timeout to each operation on the wrapped stream.
 
Callers should call enter() before doing work that is subject to timeouts, and exit() afterwards. The return value of exit() indicates whether a timeout was triggered.
 Note that the call to timedOut() is asynchronous, and may be called after exit().
| Constructor and Description | 
|---|
| AsyncTimeout() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | enter() | 
| boolean | exit()Returns true if the timeout occurred. | 
| protected IOException | newTimeoutException(IOException cause)Returns an  IOExceptionto represent a timeout. | 
| Sink | sink(Sink sink)Returns a new sink that delegates to  sink, using this to implement timeouts. | 
| Source | source(Source source)Returns a new source that delegates to  source, using this to implement timeouts. | 
| protected void | timedOut() | 
clearDeadline, clearTimeout, deadline, deadlineNanoTime, deadlineNanoTime, hasDeadline, throwIfReached, timeout, timeoutNanos, waitUntilNotifiedpublic final void enter()
public final boolean exit()
protected void timedOut()
public final Sink sink(Sink sink)
sink, using this to implement timeouts. This works
 best if timedOut() is overridden to interrupt sink's current operation.public final Source source(Source source)
source, using this to implement timeouts. This
 works best if timedOut() is overridden to interrupt sink's current operation.protected IOException newTimeoutException(@Nullable IOException cause)
IOException to represent a timeout. By default this method returns InterruptedIOException. If cause is non-null it is set as the cause of the
 returned exception.Copyright © 2017. All rights reserved.