This commit is contained in:
lizzie 2026-05-24 02:18:39 +00:00
parent bf6d92f845
commit 5e2901391d

View file

@ -231,11 +231,23 @@ bool Event::WaitFor(const std::chrono::nanoseconds time) {
} }
#else #else
bool Event::WaitFor(const std::chrono::nanoseconds time) { bool Event::WaitFor(const std::chrono::nanoseconds time) {
#ifdef _WIN32
auto const end = Common::g_wall_clock.GetTimeNS() + time;
while (!is_set.load() && rem > 0) {
Common::Windows::SleepForOneTick();
if (Common::g_wall_clock.GetTimeNS() > end)
break;
}
if (is_set.load())
Reset();
return true;
#else
std::unique_lock lk{mutex}; std::unique_lock lk{mutex};
if (!condvar.wait_for(lk, time, [this] { return is_set.load(); })) if (!condvar.wait_for(lk, time, [this] { return is_set.load(); }))
return false; return false;
is_set = false; is_set = false;
return true; return true;
#endif
} }
#endif #endif