Package org.aoju.bus.core.io.timout
Class AsyncTimeout
java.lang.Object
org.aoju.bus.core.io.timout.Timeout
org.aoju.bus.core.io.timout.AsyncTimeout
此超时使用后台线程在超时发生时精确地执行操作 用它来 在本地不支持超时的地方实现超时,例如对阻塞的套接字操作.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidenter()final booleanexit()Returns true if the timeout occurred.protected IOExceptionnewTimeoutException(IOException cause) Returns anIOExceptionto represent a timeout.final SinkReturns a new sink that delegates tosink, using this to implement timeouts.final SourceReturns a new source that delegates tosource, using this to implement timeouts.protected voidtimedOut()Methods inherited from class org.aoju.bus.core.io.timout.Timeout
clearDeadline, clearTimeout, deadline, deadlineNanoTime, deadlineNanoTime, hasDeadline, throwIfReached, timeout, timeoutNanos, waitUntilNotified
-
Constructor Details
-
AsyncTimeout
public AsyncTimeout()
-
-
Method Details
-
enter
public final void enter() -
exit
public final boolean exit()Returns true if the timeout occurred. -
timedOut
-
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. -
newTimeoutException
Returns anIOExceptionto represent a timeout. By default this method returnsInterruptedIOException. Ifcauseis non-null it is set as the cause of the returned exception.
-