All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.fix.stdlib.ratelimiter.RateLimiter Maven / Gradle / Ivy

There is a newer version: 3.1.4
Show newest version
package ru.fix.stdlib.ratelimiter;

import java.time.temporal.TemporalUnit;

public interface RateLimiter extends AutoCloseable {

    /**
     * Get configured rate limit
     */
    double getRate();

    /**
     * Try to acquire permit without waiting for it to become available.
     *
     * @return true if permit has been acquired false otherwise
     */
    boolean tryAcquire();

    /**
     * Try to acquire permit. If it isn't immediately available waits for it specified timeout.
     *
     * @return true if permit has been acquired false otherwise
     */
    boolean tryAcquire(long timeout, TemporalUnit unit);

    /**
     * Update configuration
     */
    void updateRate(int permitsPerSecond);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy