New answers tagged

1

With cv.wait_for(... do i need the loop around it to catch spurious wakes? You should've read the answer better or checked the C++ reference for std::condition_variable. When you supply a predicate (the condition lambda) to wait, wait_for, wait_until the function already has a loop inside it to deal with spurious wake ups. It will exit only once the ...


1

I see two main problems in this approach Creating a thread for each timer is extremely wasteful Running the callback synchronously with the timer can lead to all sorts of problems as you mention. The usual design for a high-performance timer is to have a single thread that waits for the next timer to fire and queues the callback to some work-queue. The ...


1

Everything should be wrapped in a function, for easier reading.. The alarm looks good!


Top 50 recent answers are included