Class AsyncQueue<T>

    • Constructor Detail

      • AsyncQueue

        public AsyncQueue​(int targetQueueSize,
                          Executor executor)
    • Method Detail

      • isFinished

        public boolean isFinished()
        Returns true if all future attempts to retrieve elements from this queue are guaranteed to return empty.
      • finish

        public void finish()
      • offer

        public com.google.common.util.concurrent.ListenableFuture<Void> offer​(T element)
      • size

        public int size()
      • getBatchAsync

        public com.google.common.util.concurrent.ListenableFuture<List<T>> getBatchAsync​(int maxSize)
      • getNotEmptySignal

        protected com.google.common.util.concurrent.SettableFuture<Void> getNotEmptySignal()
      • borrowBatchAsync

        public <O> com.google.common.util.concurrent.ListenableFuture<O> borrowBatchAsync​(int maxSize,
                                                                                          Function<List<T>,​AsyncQueue.BorrowResult<T,​O>> function)
        Invoke function with up to maxSize elements removed from the head of the queue, and insert elements in the return value to the tail of the queue.

        If no element is currently available, invocation of function will be deferred until some element is available, or no more elements will be. Spurious invocation of function is possible.

        Insertion through return value of function will be effective even if finish() has been invoked. When borrow (of a non-empty list) is ongoing, isFinished() will return false. If an empty list is supplied to function, it must not return a result indicating intention to insert elements into the queue.