Class PromiseTask<V>

    • Field Detail

      • COMPLETED

        private static final java.lang.Runnable COMPLETED
      • CANCELLED

        private static final java.lang.Runnable CANCELLED
      • FAILED

        private static final java.lang.Runnable FAILED
      • task

        private java.lang.Object task
    • Constructor Detail

      • PromiseTask

        PromiseTask​(EventExecutor executor,
                    java.lang.Runnable runnable,
                    V result)
      • PromiseTask

        PromiseTask​(EventExecutor executor,
                    java.lang.Runnable runnable)
      • PromiseTask

        PromiseTask​(EventExecutor executor,
                    java.util.concurrent.Callable<V> callable)
    • Method Detail

      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public final boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • runTask

        V runTask()
           throws java.lang.Throwable
        Throws:
        java.lang.Throwable
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Specified by:
        run in interface java.util.concurrent.RunnableFuture<V>
      • clearTaskAfterCompletion

        private boolean clearTaskAfterCompletion​(boolean done,
                                                 java.lang.Runnable result)
      • setFailure

        public final Promise<V> setFailure​(java.lang.Throwable cause)
        Description copied from interface: Promise
        Marks this future as a failure and notifies all listeners. If it is success or failed already it will throw an IllegalStateException.
        Specified by:
        setFailure in interface Promise<V>
        Overrides:
        setFailure in class DefaultPromise<V>
      • setFailureInternal

        protected final Promise<V> setFailureInternal​(java.lang.Throwable cause)
      • tryFailure

        public final boolean tryFailure​(java.lang.Throwable cause)
        Description copied from interface: Promise
        Marks this future as a failure and notifies all listeners.
        Specified by:
        tryFailure in interface Promise<V>
        Overrides:
        tryFailure in class DefaultPromise<V>
        Returns:
        true if and only if successfully marked this future as a failure. Otherwise false because this future is already marked as either a success or a failure.
      • tryFailureInternal

        protected final boolean tryFailureInternal​(java.lang.Throwable cause)
      • setSuccess

        public final Promise<V> setSuccess​(V result)
        Description copied from interface: Promise
        Marks this future as a success and notifies all listeners. If it is success or failed already it will throw an IllegalStateException.
        Specified by:
        setSuccess in interface Promise<V>
        Overrides:
        setSuccess in class DefaultPromise<V>
      • setSuccessInternal

        protected final Promise<V> setSuccessInternal​(V result)
      • trySuccess

        public final boolean trySuccess​(V result)
        Description copied from interface: Promise
        Marks this future as a success and notifies all listeners.
        Specified by:
        trySuccess in interface Promise<V>
        Overrides:
        trySuccess in class DefaultPromise<V>
        Returns:
        true if and only if successfully marked this future as a success. Otherwise false because this future is already marked as either a success or a failure.
      • trySuccessInternal

        protected final boolean trySuccessInternal​(V result)
      • setUncancellable

        public final boolean setUncancellable()
        Description copied from interface: Promise
        Make this future impossible to cancel.
        Specified by:
        setUncancellable in interface Promise<V>
        Overrides:
        setUncancellable in class DefaultPromise<V>
        Returns:
        true if and only if successfully marked this future as uncancellable or it is already done without being cancelled. false if this future has been cancelled already.
      • setUncancellableInternal

        protected final boolean setUncancellableInternal()
      • cancel

        public boolean cancel​(boolean mayInterruptIfRunning)
        Description copied from class: DefaultPromise
        If the cancellation was successful it will fail the future with a CancellationException.
        Specified by:
        cancel in interface Future<V>
        Specified by:
        cancel in interface java.util.concurrent.Future<V>
        Overrides:
        cancel in class DefaultPromise<V>
        Parameters:
        mayInterruptIfRunning - this value has no effect in this implementation.