News for hackers. Stuff that matters.
Re:Please put units in names by gpderetta on Monday March 21, 2022 @08:41AM (#30753387)
In fact std::thread::sleep doesn't exist. There's sleep_for and sleep_until. Time deltas and time points are incompatible at the type level, so you have to do:

   std::this_thread::sleep_until(std::chrono::system_clock::now() + 300ms)
That's true for all functions that take timeouts (At least since C++11).

edit: s/thread/this_thread/

Re:Please put units in names by eMSF on Monday March 21, 2022 @08:54AM (#30753528)
GP's snippet was in Rust (not that I know if it's valid Rust code).

However, in C++ std::thread is a class and it does not have a static member function sleep_until. (However, std::this_thread, which is a namespace, does have such a function).

Re:Please put units in names by gpderetta on Monday March 21, 2022 @09:00AM (#30753587)
D'oh! Thanks for the correction! Rust using std:: for its standard library does make some code snippets ambiguous!
Re:Please put units in names by eMSF on Monday March 21, 2022 @09:09AM (#30753680)
Yeah, I agree. :-)