public final class SerializedSuspendableExecutionContext extends AbstractNodeQueue<java.lang.Runnable> implements java.lang.Runnable, scala.concurrent.ExecutionContext
ExecutionContext
allows to wrap an underlying ExecutionContext
and provide guaranteed serial execution
of tasks submitted to it. On top of that it also allows for *suspending* and *resuming* processing of tasks.
WARNING: This type must never leak into User code as anything but ExecutionContext
param: throughput maximum number of tasks to be executed in serial before relinquishing the executing thread. param: context the underlying context which will be used to actually execute the submitted tasks
AbstractNodeQueue.Node<T>
Constructor and Description |
---|
SerializedSuspendableExecutionContext(int throughput,
scala.concurrent.ExecutionContext context) |
Modifier and Type | Method and Description |
---|---|
static SerializedSuspendableExecutionContext |
apply(int throughput,
scala.concurrent.ExecutionContext context) |
void |
attach() |
scala.concurrent.ExecutionContext |
context() |
void |
execute(java.lang.Runnable task) |
static int |
Off() |
static int |
On() |
void |
reportFailure(java.lang.Throwable t) |
void |
resume()
Resumes execution of tasks until
suspend is called,
if it isn't currently suspended, it is a no-op. |
void |
run() |
int |
size()
O(N)
|
void |
suspend()
Suspends execution of tasks until
resume is called,
this operation is idempotent. |
static int |
Suspended() |
java.lang.String |
toString() |
add, addNode, count, isEmpty, peek, peekNode, poll, pollNode
accumulateAndGet, compareAndSet, get, getAndAccumulate, getAndSet, getAndUpdate, lazySet, set, updateAndGet, weakCompareAndSet
public SerializedSuspendableExecutionContext(int throughput, scala.concurrent.ExecutionContext context)
public static final int Off()
public static final int On()
public static final int Suspended()
public static SerializedSuspendableExecutionContext apply(int throughput, scala.concurrent.ExecutionContext context)
public scala.concurrent.ExecutionContext context()
public final void resume()
suspend
is called,
if it isn't currently suspended, it is a no-op.
This operation is idempotent.public final void suspend()
resume
is called,
this operation is idempotent.public final void run()
run
in interface java.lang.Runnable
public final void attach()
public final void execute(java.lang.Runnable task)
execute
in interface scala.concurrent.ExecutionContext
public final void reportFailure(java.lang.Throwable t)
reportFailure
in interface scala.concurrent.ExecutionContext
public final int size()
public final java.lang.String toString()
toString
in class java.util.concurrent.atomic.AtomicReference<AbstractNodeQueue.Node<java.lang.Runnable>>