Package io.grpc.internal
Class SerializingExecutor
- java.lang.Object
-
- io.grpc.internal.SerializingExecutor
-
- All Implemented Interfaces:
java.lang.Runnable
,java.util.concurrent.Executor
public final class SerializingExecutor extends java.lang.Object implements java.util.concurrent.Executor, java.lang.Runnable
Executor ensuring that allRunnable
tasks submitted are executed in order using the providedExecutor
, and serially such that no two will ever be running at the same time.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SerializingExecutor.AtomicHelper
private static class
SerializingExecutor.FieldUpdaterAtomicHelper
private static class
SerializingExecutor.SynchronizedAtomicHelper
-
Field Summary
Fields Modifier and Type Field Description private static SerializingExecutor.AtomicHelper
atomicHelper
private java.util.concurrent.Executor
executor
Underlying executor that all submitted Runnable objects are run on.private static java.util.logging.Logger
log
private static int
RUNNING
private java.util.Queue<java.lang.Runnable>
runQueue
A list of Runnables to be run in order.private int
runState
private static int
STOPPED
-
Constructor Summary
Constructors Constructor Description SerializingExecutor(java.util.concurrent.Executor executor)
Creates a SerializingExecutor, running tasks usingexecutor
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(java.lang.Runnable r)
Runs the given runnable strictly after all Runnables that were submitted before it, and using theexecutor
passed to the constructor.private static SerializingExecutor.AtomicHelper
getAtomicHelper()
void
run()
private void
schedule(java.lang.Runnable removable)
void
setExecutor(java.util.concurrent.Executor executor)
Only call this from this SerializingExecutor Runnable, so that the executor is immediately visible to this SerializingExecutor executor.
-
-
-
Field Detail
-
log
private static final java.util.logging.Logger log
-
atomicHelper
private static final SerializingExecutor.AtomicHelper atomicHelper
-
STOPPED
private static final int STOPPED
- See Also:
- Constant Field Values
-
RUNNING
private static final int RUNNING
- See Also:
- Constant Field Values
-
executor
private java.util.concurrent.Executor executor
Underlying executor that all submitted Runnable objects are run on.
-
runQueue
private final java.util.Queue<java.lang.Runnable> runQueue
A list of Runnables to be run in order.
-
runState
private volatile int runState
-
-
Method Detail
-
getAtomicHelper
private static SerializingExecutor.AtomicHelper getAtomicHelper()
-
setExecutor
public void setExecutor(java.util.concurrent.Executor executor)
Only call this from this SerializingExecutor Runnable, so that the executor is immediately visible to this SerializingExecutor executor.
-
execute
public void execute(java.lang.Runnable r)
Runs the given runnable strictly after all Runnables that were submitted before it, and using theexecutor
passed to the constructor. .- Specified by:
execute
in interfacejava.util.concurrent.Executor
-
schedule
private void schedule(@Nullable java.lang.Runnable removable)
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
-