package com.speedment.tool.core.internal.util;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

/**
 * Throttles requests so that they are only invoked at a maximum frequency. If
 * more calls are made, others will be dropped.
 * <p>
 * This class is concurrent.
 *
 * @author Emil Forslund
 * @since  3.0.16
 */
public final class Throttler {

    private final ConcurrentHashMap<String, AtomicLong> timers;
    private final long millis;

    private Throttler(long millis) {
        this.millis   = millis;
        this.timers = new ConcurrentHashMap<>();
    }

    /**
     * Attempts to invoke the specified {@code runnable} if no other action with
     * the same specifier has been called recently. Otherwise, the method will
     * return with no effect.
     *
     * @param action    the action specifier
     * @param runnable  the callable action to invoke
     */
    public void call(String action, Runnable runnable) {
        final long now = now();
        final AtomicLong timer = timers.computeIfAbsent(action, a -> new AtomicLong(0));
        if (now == timer.updateAndGet(
            lastCall -> lastCall + millis < now
                ? now : lastCall
        )) runnable.run();
    }

    private static long now() {
        return System.currentTimeMillis();
    }
}

@@ -385,16 +385,360 @@
 tler %7B%0A%0A
+    /**%0A     * Returns a %7B@link Throttler%7D that never executes the same request more%0A     * than once every %7B@code millis%7D.%0A     *%0A     * @param millis  minimum frequency in milliseconds%0A     * @return        the created throttler%0A     */%0A    public static Throttler limitToOnceEvery(long millis) %7B%0A        return new Throttler(millis);%0A    %7D%0A%0A
     priv

Add static constructor for Throttler