Can I get a C++ tip from any passing 400-pound C whales?
In Windows, you can say "wait for a certain object to become signaled, or until X milliseconds pass", by simply:
WaitForSingleObject(handle, msecWait);
Which you've been able to do since approximately the Jurassic period.
What's the
best way of doing the same in modern C++ using the std::thread library?
The most obvious analog, using a
std::condition_variable
, seems like a hack.
(example:
https://en.cppreference.com/w/cpp/thread/stop_callback)
I've also seen suggestions of using a
std::future
that you can either wait for or have it return early if "signaled".