Package io.airlift.concurrent
Class AsyncSemaphore<T>
- java.lang.Object
-
- io.airlift.concurrent.AsyncSemaphore<T>
-
@ThreadSafe public class AsyncSemaphore<T> extends Object
Guarantees that no more than maxPermits of tasks will be run concurrently. The class will rely on the ListenableFuture returned by the submitter function to determine when a task has been completed. The submitter function NEEDS to be thread-safe and is recommended to do the bulk of its work asynchronously.
-
-
Constructor Summary
Constructors Constructor Description AsyncSemaphore(int maxPermits, Executor submitExecutor, Function<T,com.google.common.util.concurrent.ListenableFuture<?>> submitter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.util.concurrent.ListenableFuture<Void>submit(T task)
-