Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
*.exe
*.out
*.app

# Build directories
build/
8 changes: 5 additions & 3 deletions wheel_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::chrono::milliseconds>
(end_time - startTime_).count() / INTERVAL.count();
Expand Down Expand Up @@ -81,7 +81,7 @@ class WheelTimer {
}

std::vector<uint32_t> Update() {
auto now = std::chrono::system_clock::now();
auto now = Clock::now();
auto now_tick = std::chrono::duration_cast<std::chrono::milliseconds>
(now - startTime_).count() / INTERVAL.count();
std::vector<uint32_t> ret;
Expand Down Expand Up @@ -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<TimerNodePtr> buckets_[WHEEL_BUCKETS][WHEEL_SIZE];
std::unordered_map<uint32_t, TimerNodePtr> timer_map_;
Expand Down
Loading