Package io.grpc.stub

Class 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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.logging.Logger log  
      private static java.lang.Object SHUTDOWN  
      private java.lang.Object waiter  
    • 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 to waitAndDrain(), 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.AbstractQueue

        clear, element, remove
      • 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
      • Methods inherited from interface java.util.Collection

        clear, containsAll, equals, hashCode, parallelStream, removeAll, removeIf, retainAll, stream
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Queue

        element, remove
    • Field Detail

      • log

        private static final java.util.logging.Logger log
      • SHUTDOWN

        private static final java.lang.Object SHUTDOWN
      • waiter

        private volatile java.lang.Object waiter
    • Constructor Detail

      • ThreadlessExecutor

        ThreadlessExecutor()
    • 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 to waitAndDrain(), 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 interface java.util.concurrent.Executor