public interface Throttle
A given throttle limits the amount of concurrently executing promise, effectively limiting concurrency.
The queueing employed by the throttle is generally fair (i.e. oldest promises execute first), but this is not completely guaranteed.
PromiseOperations.throttled(Throttle)
Modifier and Type | Method and Description |
---|---|
int |
getActive()
How many throttled promises are currently executing.
|
int |
getSize()
The size of this throttle.
|
int |
getWaiting()
The number of throttled promises that are waiting to execute (that is, the queue size).
|
static Throttle |
ofSize(int size)
Create a new throttle of the given size.
|
<T> Promise<T> |
throttle(Promise<T> promise)
Throttles the given promise.
|
static Throttle ofSize(int size)
size
- the desired size<T> Promise<T> throttle(Promise<T> promise)
T
- the type of promised valuepromise
- the promise to throttleint getSize()
The throttle guarantees that no more than this number of promises that were throttled via throttle(Promise)
will execute at the same time.
int getActive()
int getWaiting()