Class SharedBlockingCallback.Blocker

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Callback, Invocable
    Enclosing class:
    SharedBlockingCallback

    public class SharedBlockingCallback.Blocker
    extends java.lang.Object
    implements Callback, java.io.Closeable
    A Closeable Callback. Uses the auto close mechanism to check block has been called OK.

    Implements Callback because calls to this callback do not blocak, rather they wakeup the thread that is blocked in block()

    • Constructor Detail

      • Blocker

        protected Blocker()
    • Method Detail

      • failed

        public void failed​(java.lang.Throwable cause)
        Description copied from interface: Callback

        Callback invoked when the operation fails.

        Specified by:
        failed in interface Callback
        Parameters:
        cause - the reason for the operation failure
      • block

        public void block()
                   throws java.io.IOException
        Block until the Callback has succeeded or failed and after the return leave in the state to allow reuse. This is useful for code that wants to repeatable use a FutureCallback to convert an asynchronous API to a blocking API.
        Throws:
        java.io.IOException - if exception was caught during blocking, or callback was cancelled
      • close

        public void close()
        Check the Callback has succeeded or failed and after the return leave in the state to allow reuse.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object