thread/win32: add sleep_until implementation
This commit is contained in:
parent
425e933f62
commit
df1f5fe8fd
@ -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>
|
template <class Clock, class Duration>
|
||||||
void sleep_until (std::chrono::time_point<Clock,Duration> const& sleep_time);
|
void sleep_until (std::chrono::time_point<Clock,Duration> const& sleep_time);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user