diff options
Diffstat (limited to 'src/mbgl/util/throttler.hpp')
-rw-r--r-- | src/mbgl/util/throttler.hpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mbgl/util/throttler.hpp b/src/mbgl/util/throttler.hpp new file mode 100644 index 0000000000..175de7ccaf --- /dev/null +++ b/src/mbgl/util/throttler.hpp @@ -0,0 +1,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 |