X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fapp%2FIntervalTimer.hpp;fp=src%2Fapp%2FIntervalTimer.hpp;h=0d6790be20850ebfb9276fc62f88b09408793917;hb=6f94235a5b7c140852703e60c8a74760b8b61d99;hp=e5d02481e676d9c618388b626b9931f8caf6fc5a;hpb=f2f254f8d576b48fde9305c3d2927552d1d4c20d;p=blank.git diff --git a/src/app/IntervalTimer.hpp b/src/app/IntervalTimer.hpp index e5d0248..0d6790b 100644 --- a/src/app/IntervalTimer.hpp +++ b/src/app/IntervalTimer.hpp @@ -4,9 +4,15 @@ namespace blank { +/// Timer that hits every n milliseconds. Resolution is that of the +/// delta values passed to Update(), minimum 1ms. +/// Also tracks the number of iterations as well as milliseconds +/// passed. class IntervalTimer { public: + /// Create a timer that hits every interval_ms milliseconds. + /// Initial state is stopped. explicit IntervalTimer(int interval_ms) noexcept : intv(interval_ms) { } @@ -21,6 +27,7 @@ public: bool Running() const noexcept { return speed != 0; } + /// true if an interval boundary was passed by the last call to Update() bool Hit() const noexcept { return Running() && value % intv < last_dt; }