Package io.trino.plugin.hive.util
Class AsyncQueue<T>
- java.lang.Object
-
- io.trino.plugin.hive.util.AsyncQueue<T>
-
- Direct Known Subclasses:
ThrottledAsyncQueue
@ThreadSafe public class AsyncQueue<T> extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAsyncQueue.BorrowResult<T,R>
-
Constructor Summary
Constructors Constructor Description AsyncQueue(int targetQueueSize, Executor executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <O> com.google.common.util.concurrent.ListenableFuture<O>borrowBatchAsync(int maxSize, Function<List<T>,AsyncQueue.BorrowResult<T,O>> function)Invokefunctionwith up tomaxSizeelements removed from the head of the queue, and insert elements in the return value to the tail of the queue.voidfinish()com.google.common.util.concurrent.ListenableFuture<List<T>>getBatchAsync(int maxSize)protected com.google.common.util.concurrent.SettableFuture<Void>getNotEmptySignal()booleanisFinished()Returns true if all future attempts to retrieve elements from this queue are guaranteed to return empty.com.google.common.util.concurrent.ListenableFuture<Void>offer(T element)intsize()
-
-
-
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()
-
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)Invokefunctionwith up tomaxSizeelements 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
functionwill be deferred until some element is available, or no more elements will be. Spurious invocation offunctionis possible.Insertion through return value of
functionwill be effective even iffinish()has been invoked. When borrow (of a non-empty list) is ongoing,isFinished()will return false. If an empty list is supplied tofunction, it must not return a result indicating intention to insert elements into the queue.
-
-