Package ratpack.exec

Interface Throttle

  • public interface Throttle
    Limits the concurrency of operations, typically access to an external resource.

    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.

    See Also:
    • Method Detail

      • ofSize

        static Throttle ofSize​(int size)
        Create a new throttle of the given size.
        size - the desired size
        a new throttle of the given size
      • unlimited

        static Throttle unlimited()
        Create a new throttle that does not limit concurrency.
        an unlimited throttle
      • throttle

        <T> Promise<T> throttle​(Promise<T> promise)
        Throttles the given promise.
        Type Parameters:
        T - the type of promised value
        promise - the promise to throttle
        the throttled promise
      • getSize

        int getSize()
        The size of this throttle.

        The throttle guarantees that no more than this number of promises that were throttled via throttle(Promise) will execute at the same time.

        Returns < 1 if the throttle is unlimited.

        the throttle size
      • getActive

        int getActive()
        How many throttled promises are currently executing.
        how many throttled promises are currently executing
      • getWaiting

        int getWaiting()
        The number of throttled promises that are waiting to execute (that is, the queue size).
        the number of promises waiting to execute