Interface Throttle

  • All Known Implementing Classes:
    RateThrottle

    public interface Throttle
    Throttle can make a decision about the specified thing to pass or to wait. The throttle calls are not blocking so the caller should block if the throttle tells so.
    • Method Detail

      • tryAcquire

        boolean tryAcquire()
        Request a permit about a thing
        Returns:
        true if the thing should be passed, false otherwise
      • tryAcquire

        int tryAcquire​(int times)
        Request permits about a set of things
        Parameters:
        times - how many permits is requested
        Returns:
        how many permits are got