Class InterruptibleTask<T>

java.lang.Object
java.util.concurrent.atomic.AtomicReference<Runnable>
com.google.common.util.concurrent.InterruptibleTask<T>
All Implemented Interfaces:
Serializable, Runnable
Direct Known Subclasses:
CombinedFuture.CombinedFutureInterruptibleTask, TrustedListenableFutureTask.TrustedFutureInterruptibleAsyncTask, TrustedListenableFutureTask.TrustedFutureInterruptibleTask

abstract class InterruptibleTask<T> extends AtomicReference<Runnable> implements Runnable
  • Field Details

    • DONE

      private static final Runnable DONE
    • PARKED

      private static final Runnable PARKED
    • MAX_BUSY_WAIT_SPINS

      private static final int MAX_BUSY_WAIT_SPINS
      See Also:
  • Constructor Details

    • InterruptibleTask

      InterruptibleTask()
  • Method Details

    • run

      public final void run()
      Specified by:
      run in interface Runnable
    • waitForInterrupt

      private void waitForInterrupt(Thread currentThread)
    • isDone

      abstract boolean isDone()
      Called before runInterruptibly - if true, runInterruptibly and afterRanInterruptibly will not be called.
    • runInterruptibly

      abstract T runInterruptibly() throws Exception
      Do interruptible work here - do not complete Futures here, as their listeners could be interrupted.
      Throws:
      Exception
    • afterRanInterruptiblySuccess

      abstract void afterRanInterruptiblySuccess(T result)
      Any interruption that happens as a result of calling interruptTask will arrive before this method is called. Complete Futures here.
    • afterRanInterruptiblyFailure

      abstract void afterRanInterruptiblyFailure(Throwable error)
      Any interruption that happens as a result of calling interruptTask will arrive before this method is called. Complete Futures here.
    • interruptTask

      final void interruptTask()
      Interrupts the running task. Because this internally calls Thread.interrupt() which can in turn invoke arbitrary code it is not safe to call while holding a lock.
    • toString

      public final String toString()
      Overrides:
      toString in class AtomicReference<Runnable>
    • toPendingString

      abstract String toPendingString()