summaryrefslogtreecommitdiff
path: root/src/mbgl/util/throttler.hpp
blob: 175de7ccaf71bedf5b04e52269323c344272c618 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/timer.hpp>

namespace mbgl {
namespace util {

class Throttler {
public:
    Throttler(Duration frequency, std::function<void()>&& function);
    
    void invoke();
private:
    Duration frequency;
    std::function<void()> function;
    
    Timer timer;
    bool pendingInvocation;
    TimePoint lastInvocation;
};

} // namespace util
} // namespace mbgl