类 RateLimiter


  • public final class RateLimiter
    extends java.lang.Object
    A very simple RateLimiter impl, For limiting ops count in specific time span
    • 方法概要

      所有方法 静态方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      void acquire()
      Acquire one permit, block if needed
      void acquire​(int n)
      Acquire n permits, block if needed
      static RateLimiter of​(double permitsPerSecond)
      Create a new RateLimiter
      double permitsPerSecond()  
      boolean tryAcquire()
      Try to acquire one permit, not block.
      boolean tryAcquire​(int n)
      Try to acquire n permits, not block.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 方法详细资料

      • of

        public static RateLimiter of​(double permitsPerSecond)
        Create a new RateLimiter
        参数:
        permitsPerSecond - how many permits should generated in one second, should be larger than(or eq) zero
        抛出:
        java.lang.IllegalArgumentException - if permits value is invalid
      • acquire

        public void acquire()
        Acquire one permit, block if needed
      • acquire

        public void acquire​(int n)
        Acquire n permits, block if needed
      • tryAcquire

        public boolean tryAcquire()
        Try to acquire one permit, not block.
        返回:
        true if acquire permits succeed, false if do not have enough available permits.
      • tryAcquire

        public boolean tryAcquire​(int n)
        Try to acquire n permits, not block.
        返回:
        true if acquire permits succeed, false if do not have enough available permits.
      • permitsPerSecond

        public double permitsPerSecond()