Package io.grpc.stub
Class ClientCalls.ThreadlessExecutor
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- java.util.concurrent.ConcurrentLinkedQueue<java.lang.Runnable>
-
- io.grpc.stub.ClientCalls.ThreadlessExecutor
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<java.lang.Runnable>
,java.util.Collection<java.lang.Runnable>
,java.util.concurrent.Executor
,java.util.Queue<java.lang.Runnable>
- Enclosing class:
- ClientCalls
private static final class ClientCalls.ThreadlessExecutor extends java.util.concurrent.ConcurrentLinkedQueue<java.lang.Runnable> implements java.util.concurrent.Executor
-
-
Constructor Summary
Constructors Constructor Description ThreadlessExecutor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(java.lang.Runnable runnable)
private static void
runQuietly(java.lang.Runnable runnable)
void
shutdown()
Called after final call towaitAndDrain()
, from same thread.private static void
throwIfInterrupted()
void
waitAndDrain()
Waits until there is a Runnable, then executes it and all queued Runnables after it.-
Methods inherited from class java.util.concurrent.ConcurrentLinkedQueue
add, addAll, contains, isEmpty, iterator, offer, peek, poll, remove, size, spliterator, toArray, toArray
-
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
waitAndDrain
public void waitAndDrain() throws java.lang.InterruptedException
Waits until there is a Runnable, then executes it and all queued Runnables after it. Must only be called by one thread at a time.- Throws:
java.lang.InterruptedException
-
shutdown
public void shutdown()
Called after final call towaitAndDrain()
, from same thread.
-
runQuietly
private static void runQuietly(java.lang.Runnable runnable)
-
throwIfInterrupted
private static void throwIfInterrupted() throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
execute
public void execute(java.lang.Runnable runnable)
- Specified by:
execute
in interfacejava.util.concurrent.Executor
-
-