Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.robrua.orianna.type.api;
 
 import java.util.Set;

Handles multiple rate limits

Author(s):
Rob Rua (FatalElement - NA) (robrua@alumni.cmu.edu)
public class MultiRateLimiter implements RateLimiter {
    private final Set<SingleRateLimiterlimits;

    

Parameters:
limits the rate limits to use
    public MultiRateLimiter(final Collection<RateLimitlimits) {
        this. = new HashSet<>();
        for(final RateLimit limit : limits) {
            this..add(new SingleRateLimiter(limit));
        }
    }

    

Parameters:
limits the rate limits to use
    public MultiRateLimiter(final RateLimit... limits) {
        this(Arrays.asList(limits));
    }
    @Override
    public synchronized void registerCall() {
        for(final RateLimiter limit : ) {
            limit.registerCall();
        }
    }
    @Override
    public synchronized void waitForCall() {
        for(final RateLimiter limit : ) {
            limit.waitForCall();
        }
    }
New to GrepCode? Check out our FAQ X