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()

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Throwable _state  
      • Fields inherited from interface org.eclipse.jetty.util.Callback

        NOOP
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Blocker()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void block()
      Block until the Callback has succeeded or failed and after the return leave in the state to allow reuse.
      void close()
      Check the Callback has succeeded or failed and after the return leave in the state to allow reuse.
      void failed​(java.lang.Throwable cause)
      Callback invoked when the operation fails.
      Invocable.InvocationType getInvocationType()  
      void succeeded()
      Callback invoked when the operation completes.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • _state

        private java.lang.Throwable _state
    • 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