类 AsyncTimeout
java.lang.Object
com.lark.oapi.okio.Timeout
com.lark.oapi.okio.AsyncTimeout
This timeout uses a background thread to take action exactly when the timeout occurs. Use this to
implement timeouts where they aren't supported natively, such as to sockets that are blocked on
writing.
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(com.lark.oapi.okio.Sink) and source(com.lark.oapi.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().
-
字段概要
-
构造器概要
构造器 -
方法概要
从类继承的方法 com.lark.oapi.okio.Timeout
clearDeadline, clearTimeout, deadline, deadlineNanoTime, deadlineNanoTime, hasDeadline, throwIfReached, timeout, timeoutNanos, waitUntilNotified
-
构造器详细资料
-
AsyncTimeout
public AsyncTimeout()
-
-
方法详细资料
-
enter
public final void enter() -
exit
public final boolean exit()Returns true if the timeout occurred. -
sink
Returns a new sink that delegates tosink, using this to implement timeouts. This works best iftimedOut()is overridden to interruptsink's current operation. -
source
Returns a new source that delegates tosource, using this to implement timeouts. This works best iftimedOut()is overridden to interruptsink's current operation.
-