clocker: minor simplification
This commit is contained in:
parent
1490334f87
commit
71c7ac8bb9
@ -82,14 +82,14 @@ class Clocker {
|
||||
Clocker(std::chrono::milliseconds period): period(period) {};
|
||||
void tick() {
|
||||
if(next_tick == std::chrono::time_point<std::chrono::steady_clock>::min()) {
|
||||
next_tick = std::chrono::steady_clock::now() + period;
|
||||
next_tick = std::chrono::steady_clock::now();
|
||||
} else {
|
||||
next_tick += period;
|
||||
auto duration = next_tick - std::chrono::steady_clock::now();
|
||||
if(duration >= duration.zero())
|
||||
std::this_thread::sleep_for(duration);
|
||||
else
|
||||
std::cerr << "missed tick" << std::endl;
|
||||
next_tick += period;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user