Class PromiseTask<V>

All Implemented Interfaces:
Future<V>, Promise<V>, Runnable, Future<V>, RunnableFuture<V>
Direct Known Subclasses:
ScheduledFutureTask, UnorderedThreadPoolEventExecutor.RunnableScheduledFutureTask

class PromiseTask<V> extends DefaultPromise<V> implements RunnableFuture<V>
  • Field Details

    • COMPLETED

      private static final Runnable COMPLETED
    • CANCELLED

      private static final Runnable CANCELLED
    • FAILED

      private static final Runnable FAILED
    • task

      private Object task
  • Constructor Details

  • Method Details

    • hashCode

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

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • runTask

      V runTask() throws Throwable
      Throws:
      Throwable
    • run

      public void run()
      Specified by:
      run in interface Runnable
      Specified by:
      run in interface RunnableFuture<V>
    • clearTaskAfterCompletion

      private boolean clearTaskAfterCompletion(boolean done, Runnable result)
    • setFailure

      public final Promise<V> setFailure(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(Throwable cause)
    • tryFailure

      public final boolean tryFailure(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(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 Future<V>
      Overrides:
      cancel in class DefaultPromise<V>
      Parameters:
      mayInterruptIfRunning - this value has no effect in this implementation.
    • toStringBuilder

      protected StringBuilder toStringBuilder()
      Overrides:
      toStringBuilder in class DefaultPromise<V>