Class InterruptibleTask<T>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  InterruptibleTask.Blocker
      Using this as the blocker object allows introspection and debugging tools to see that the currentRunner thread is blocked on the progress of the interruptor thread, which can help identify deadlocks.
      private static class  InterruptibleTask.DoNothingRunnable  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.Runnable DONE  
      private static int MAX_BUSY_WAIT_SPINS  
      private static java.lang.Runnable PARKED  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) abstract void afterRanInterruptiblyFailure​(java.lang.Throwable error)
      Any interruption that happens as a result of calling interruptTask will arrive before this method is called.
      (package private) abstract void afterRanInterruptiblySuccess​(T result)
      Any interruption that happens as a result of calling interruptTask will arrive before this method is called.
      (package private) void interruptTask()
      Interrupts the running task.
      (package private) abstract boolean isDone()
      Called before runInterruptibly - if true, runInterruptibly and afterRanInterruptibly will not be called.
      void run()  
      (package private) abstract T runInterruptibly()
      Do interruptible work here - do not complete Futures here, as their listeners could be interrupted.
      (package private) abstract java.lang.String toPendingString()  
      java.lang.String toString()  
      private void waitForInterrupt​(java.lang.Thread currentThread)  
      • Methods inherited from class java.util.concurrent.atomic.AtomicReference

        accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DONE

        private static final java.lang.Runnable DONE
      • PARKED

        private static final java.lang.Runnable PARKED
    • Constructor Detail

      • InterruptibleTask

        InterruptibleTask()
    • Method Detail

      • run

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

        private void waitForInterrupt​(java.lang.Thread currentThread)
      • isDone

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

        abstract T runInterruptibly()
                             throws java.lang.Exception
        Do interruptible work here - do not complete Futures here, as their listeners could be interrupted.
        Throws:
        java.lang.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​(java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.util.concurrent.atomic.AtomicReference<java.lang.Runnable>
      • toPendingString

        abstract java.lang.String toPendingString()