c++ - implement waiting timer using only the standard library -
what standard c++ ways exist implement waiting timer? is, code trigger timer callback , , wait timeout occur (not waste any, or little, cpu cycles). there must finite number of ways std::
. using <thread>
, timeout feature of condition variables. seems wasteful have spawn thread each timer.
std::this_thread::sleep_for()
, std::this_thread::sleep_until()
useful unless you're spawning new thread, cannot other work @ same time.
Comments
Post a Comment