diff --git a/.gitignore b/.gitignore index 259148f..ba1af04 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,6 @@ *.exe *.out *.app + +# Build directories +build/ diff --git a/wheel_timer.h b/wheel_timer.h index e623b9e..4a0934f 100644 --- a/wheel_timer.h +++ b/wheel_timer.h @@ -35,7 +35,7 @@ class WheelTimer { uint32_t Add(uint32_t delay_ms) { auto timeout = std::chrono::milliseconds(delay_ms); - auto now = std::chrono::system_clock::now(); + auto now = Clock::now(); auto end_time = now + timeout; auto end_tick = std::chrono::duration_cast (end_time - startTime_).count() / INTERVAL.count(); @@ -81,7 +81,7 @@ class WheelTimer { } std::vector Update() { - auto now = std::chrono::system_clock::now(); + auto now = Clock::now(); auto now_tick = std::chrono::duration_cast (now - startTime_).count() / INTERVAL.count(); std::vector ret; @@ -166,7 +166,9 @@ class WheelTimer { private: uint32_t timer_id_ = 0; - std::chrono::system_clock::time_point startTime_ = std::chrono::system_clock::now(); + using Clock = std::chrono::steady_clock; + + Clock::time_point startTime_ = Clock::now(); int64_t expireTick_ = 0; std::vector buckets_[WHEEL_BUCKETS][WHEEL_SIZE]; std::unordered_map timer_map_;