abstract class InterruptibleTask<T>
extends java.util.concurrent.atomic.AtomicReference<java.lang.Runnable>
implements java.lang.Runnable
Modifier and Type | Class and 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 |
Modifier and Type | Field and Description |
---|---|
private static java.lang.Runnable |
DONE |
private static int |
MAX_BUSY_WAIT_SPINS |
private static java.lang.Runnable |
PARKED |
Constructor and Description |
---|
InterruptibleTask() |
Modifier and Type | Method and 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) |
private static final java.lang.Runnable DONE
private static final java.lang.Runnable PARKED
private static final int MAX_BUSY_WAIT_SPINS
public final void run()
run
in interface java.lang.Runnable
private void waitForInterrupt(java.lang.Thread currentThread)
abstract boolean isDone()
abstract T runInterruptibly() throws java.lang.Exception
java.lang.Exception
abstract void afterRanInterruptiblySuccess(T result)
abstract void afterRanInterruptiblyFailure(java.lang.Throwable error)
final void interruptTask()
Thread.interrupt()
which can
in turn invoke arbitrary code it is not safe to call while holding a lock.public final java.lang.String toString()
toString
in class java.util.concurrent.atomic.AtomicReference<java.lang.Runnable>
abstract java.lang.String toPendingString()