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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
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 final class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) abstract void
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) final void
Interrupts the running task.(package private) abstract boolean
isDone()
Called before runInterruptibly - if true, runInterruptibly and afterRanInterruptibly will not be called.final void
run()
(package private) abstract T
Do interruptible work here - do not complete Futures here, as their listeners could be interrupted.(package private) abstract String
final String
toString()
private void
waitForInterrupt
(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
-
Field Details
-
DONE
-
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() -
waitForInterrupt
-
isDone
abstract boolean isDone()Called before runInterruptibly - if true, runInterruptibly and afterRanInterruptibly will not be called. -
runInterruptibly
Do interruptible work here - do not complete Futures here, as their listeners could be interrupted.- Throws:
Exception
-
afterRanInterruptiblySuccess
Any interruption that happens as a result of calling interruptTask will arrive before this method is called. Complete Futures here. -
afterRanInterruptiblyFailure
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 callsThread.interrupt()
which can in turn invoke arbitrary code it is not safe to call while holding a lock. -
toString
- Overrides:
toString
in classAtomicReference<Runnable>
-
toPendingString
-