thread/win32: add sleep_until implementation

This commit is contained in:
Danny Robson 2019-08-20 10:48:18 +10:00
parent 425e933f62
commit df1f5fe8fd

View File

@ -137,6 +137,19 @@ namespace cruft::thread {
}
}
template <class ClockT, class DurationT>
void
sleep_until (std::chrono::time_point<ClockT, DurationT> const& sleep_time)
{
if (ClockT::is_steady)
return sleep_for (sleep_time - ClockT::now ());
for (auto now = ClockT::now (); now < sleep_time; now = ClockT::now ())
sleep_for (sleep_time - now);
}
template <class Clock, class Duration>
void sleep_until (std::chrono::time_point<Clock,Duration> const& sleep_time);
}