Triggers a permit acquisition, returning a future that will complete when a permit gets acquired.
Triggers a permit acquisition, returning a future that will complete when a permit gets acquired.
Returns the number of active tasks that are holding on to the available permits.
Returns a future that will be complete when all the currently acquired permits are released, or in other words when the activeCount is zero.
Returns a future that will be complete when all the currently acquired permits are released, or in other words when the activeCount is zero.
This also means that we are going to wait for the acquisition and release of all enqueued promises as well.
Returns a new future, ensuring that the given source acquires an available permit from the semaphore before it is executed.
Returns a new future, ensuring that the given source acquires an available permit from the semaphore before it is executed.
The returned future also takes care of resource handling, releasing its permit after being complete.
is a function returning the Future
instance we
want to evaluate after we get the permit from the
semaphore
Releases a permit, returning it to the pool.
Releases a permit, returning it to the pool.
If there are consumers waiting on permits being available, then the first in the queue will be selected and given a permit immediately.
The
AsyncSemaphore
is an asynchronous semaphore implementation that limits the parallelism onFuture
execution.The following example instantiates a semaphore with a maximum parallelism of 10: