Class AsyncTimeout

java.lang.Object
org.miaixz.bus.core.io.timout.Timeout
org.miaixz.bus.core.io.timout.AsyncTimeout

public class AsyncTimeout extends Timeout
此超时使用后台线程在超时发生时精确地执行操作 用它来 在本地不支持超时的地方实现超时,例如对阻塞的套接字操作.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • AsyncTimeout

      public AsyncTimeout()
  • Method Details

    • enter

      public final void enter()
    • exit

      public final boolean exit()
      Returns true if the timeout occurred.
    • timedOut

      protected void timedOut()
      Invoked by the watchdog thread when the time between calls to enter() and exit() has exceeded the timeout.
    • sink

      public final Sink sink(Sink sink)
      Returns a new sink that delegates to sink, using this to implement timeouts. This works best if timedOut() is overridden to interrupt sink's current operation.
    • source

      public final Source source(Source source)
      Returns a new source that delegates to source, using this to implement timeouts. This works best if timedOut() is overridden to interrupt sink's current operation.
    • newTimeoutException

      protected IOException newTimeoutException(IOException cause)
      Returns an 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.