Use steady_clock instead of high_resolution_clock for sleeping.
This commit is contained in:
parent
f0d0ee17ea
commit
2e54844989
@ -13,12 +13,12 @@ namespace mijin
|
|||||||
template<typename Rep, typename Period>
|
template<typename Rep, typename Period>
|
||||||
Task<> c_sleep(std::chrono::duration<Rep, Period> duration)
|
Task<> c_sleep(std::chrono::duration<Rep, Period> duration)
|
||||||
{
|
{
|
||||||
auto now = std::chrono::high_resolution_clock::now();
|
auto now = std::chrono::steady_clock::now();
|
||||||
const auto end = now + duration;
|
const auto end = now + duration;
|
||||||
while (now < end)
|
while (now < end)
|
||||||
{
|
{
|
||||||
co_await c_suspend();
|
co_await c_suspend();
|
||||||
now = std::chrono::high_resolution_clock::now();
|
now = std::chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
co_return;
|
co_return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user