Class CompletableCallback

  • All Implemented Interfaces:
    Callback, Invocable

    public abstract class CompletableCallback
    extends Object
    implements Callback
    not used anymore

    A callback to be used by driver code that needs to know whether the callback has been succeeded or failed (that is, completed) just after the asynchronous operation or not, typically because further processing depends on the callback being completed. The driver code competes with the asynchronous operation to complete the callback.

    If the callback is already completed, the driver code continues the processing, otherwise it suspends it. If it is suspended, the callback will be completed some time later, and resume() or abort(Throwable) will be called to allow the application to resume the processing.

    Typical usage:
     CompletableCallback callback = new CompletableCallback()
         public void resume()
             // continue processing
         public void abort(Throwable failure)
             // abort processing
     boolean completed = callback.tryComplete();
     if (completed)
         // suspend processing, async operation not done yet
         // continue processing, async operation already done
    • Constructor Detail

      • CompletableCallback

        public CompletableCallback()
    • Method Detail

      • failed

        public void failed​(Throwable x)
        Description copied from interface: Callback

        Callback invoked when the operation fails.

        Specified by:
        failed in interface Callback
        x - the reason for the operation failure
      • resume

        public abstract void resume()
        Callback method invoked when this callback is succeeded after a first call to tryComplete().
      • abort

        public abstract void abort​(Throwable failure)
        Callback method invoked when this callback is failed.
        failure - the throwable reprsenting the callback failure
      • tryComplete

        public boolean tryComplete()
        Tries to complete this callback; driver code should call this method once after the asynchronous operation to detect whether the asynchronous operation has already completed or not.
        whether the attempt to complete was successful.