gramods
Loading...
Searching...
No Matches
RunLimited.hh
1
2#ifndef GRAMODS_CORE_RUNLIMITED
3#define GRAMODS_CORE_RUNLIMITED
4
5#include <chrono>
6
28#define GM_RUNLIMITED(CODE, SECONDS) \
29 { \
30 static std::chrono::steady_clock::time_point _gramods_last_executed; \
31 std::chrono::steady_clock::time_point _gramods_now = std::chrono::steady_clock::now(); \
32 if (_gramods_now - _gramods_last_executed > std::chrono::seconds(SECONDS)) { \
33 _gramods_last_executed = _gramods_now; \
34 CODE; \
35 } \
36 }
37
38#define GM_RUNLIMITED_BEGIN(SECONDS) \
39 { \
40 static bool _gramods_executed = false; \
41 if (!_gramods_executed) { \
42 _gramods_executed = true;
43
44#define GM_RUNLIMITED_END }}//
45
46#endif