Class FrameLimitController.TokenBucket

java.lang.Object
org.apache.hc.core5.http2.impl.nio.FrameLimitController.TokenBucket
Enclosing class:
FrameLimitController

static final class FrameLimitController.TokenBucket extends Object
Constant-time token bucket, with no locks or per-frame allocation, used to tolerate bursts and recover over time. Shared by every bucket kept by FrameLimitController; a new kind of limited frame is just another instance of this class.
  • Field Details

    • NANOS_PER_SECOND

      private static final long NANOS_PER_SECOND
      See Also:
    • capacity

      private final int capacity
    • refillPerSecond

      private final int refillPerSecond
    • fullRefillNanos

      private final long fullRefillNanos
    • tokens

      private int tokens
    • previousNanos

      private long previousNanos
    • remainder

      private long remainder
    • initialized

      private boolean initialized
  • Constructor Details

    • TokenBucket

      TokenBucket(int capacity, int refillPerSecond)
  • Method Details

    • accept

      boolean accept(long nowNanos)