19.8 Implement a Timer class (C++)

#1

It’s not clear to me how to implement the dispatch thread. The thread must be woken up when

  1. timer is expired
    -or-
  2. the new thread is added and ends up being the top of the heap.

I guess we need some combination of this_thread::sleep_for() + condition_variable::wait(). Can someone enlighten me how to do this?

Appreciated any pointer.

0 Likes