Class TrustedListenableFutureTask<V>

All Implemented Interfaces:
AbstractFuture.Trusted<V>, ListenableFuture<V>, Runnable, Future<V>, RunnableFuture<V>

class TrustedListenableFutureTask<V> extends FluentFuture.TrustedFuture<V> implements RunnableFuture<V>
A RunnableFuture that also implements the ListenableFuture interface.

This should be used in preference to ListenableFutureTask when possible for performance reasons.

  • Field Details

  • Constructor Details

    • TrustedListenableFutureTask

      TrustedListenableFutureTask(Callable<V> callable)
    • TrustedListenableFutureTask

      TrustedListenableFutureTask(AsyncCallable<V> callable)
  • Method Details

    • create

      static <V> TrustedListenableFutureTask<V> create(AsyncCallable<V> callable)
    • create

      static <V> TrustedListenableFutureTask<V> create(Callable<V> callable)
    • create

      static <V> TrustedListenableFutureTask<V> create(Runnable runnable, V result)
      Creates a ListenableFutureTask that will upon running, execute the given Runnable, and arrange that get will return the given result on successful completion.
      Parameters:
      runnable - the runnable task
      result - the result to return on successful completion. If you don't need a particular result, consider using constructions of the form: ListenableFuture<?> f = ListenableFutureTask.create(runnable, null)
    • run

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

      protected void afterDone()
      Description copied from class: AbstractFuture
      Callback method that is called exactly once after the future is completed.

      If AbstractFuture.interruptTask() is also run during completion, AbstractFuture.afterDone() runs after it.

      The default implementation of this method in AbstractFuture does nothing. This is intended for very lightweight cleanup work, for example, timing statistics or clearing fields. If your task does anything heavier consider, just using a listener with an executor.

      Overrides:
      afterDone in class AbstractFuture<V>
    • pendingToString

      @CheckForNull protected String pendingToString()
      Description copied from class: AbstractFuture
      Provide a human-readable explanation of why this future has not yet completed.
      Overrides:
      pendingToString in class AbstractFuture<V>
      Returns:
      null if an explanation cannot be provided (e.g. because the future is done).