Package org.eclipse.jetty.util.thread
Class SerializedInvoker
java.lang.Object
org.eclipse.jetty.util.thread.SerializedInvoker
Ensures serial invocation of submitted tasks.
The Invocable.InvocationType
of the Runnable
returned from this class is
always Invocable.InvocationType.BLOCKING
since a blocking task may be added to the queue
at any time.
This class was inspired by the public domain class NonBlockingMutexExecutor
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
deriveTaskName
(Runnable task) Arrange for a task to be invoked, mutually excluded from other tasks.Arrange for tasks to be invoked, mutually excluded from other tasks.protected void
void
Arrange for a task to be run, mutually excluded from other tasks.void
Arrange for tasks to be executed, mutually excluded from other tasks.toString()
-
Constructor Details
-
SerializedInvoker
public SerializedInvoker()
-
-
Method Details
-
offer
Arrange for a task to be invoked, mutually excluded from other tasks.- Parameters:
task
- The task to invoke- Returns:
- A Runnable that must be called to invoke the passed task and possibly other tasks. Null if the task will be invoked by another caller.
-
deriveTaskName
-
offer
Arrange for tasks to be invoked, mutually excluded from other tasks.- Parameters:
tasks
- The tasks to invoke- Returns:
- A Runnable that must be called to invoke the passed tasks and possibly other tasks. Null if the tasks will be invoked by another caller.
-
run
Arrange for a task to be run, mutually excluded from other tasks. This is equivalent to directly running anyRunnable
returned fromoffer(Runnable)
- Parameters:
task
- The task to invoke
-
run
Arrange for tasks to be executed, mutually excluded from other tasks. This is equivalent to directly running anyRunnable
returned fromoffer(Runnable...)
- Parameters:
tasks
- The tasks to invoke
-
toString
-
onError
-