OS: Add check for expired weak_ptr

This commit is contained in:
Tony Wasserka 2024-03-31 22:08:29 +02:00
parent e9961ad89a
commit 284feff915

View file

@ -5785,7 +5785,9 @@ void OS::ElapseTime(std::chrono::nanoseconds time) {
// TODO NOW: This should also be checked for threads waiting for arbitration or events with timeout!!!
for (auto thread_it = waiting_queue.begin(); thread_it != waiting_queue.end();) {
auto thread = thread_it->lock();
if (thread->timeout_at <= GetTimeInNanoSeconds()) {
if (!thread) {
thread_it = waiting_queue.erase(thread_it);
} else if (thread->timeout_at <= GetTimeInNanoSeconds()) {
thread->GetLogger()->info("{}Waking up thread after timeout", ThreadPrinter{*thread});
// status==Sleeping corresponds to WaitSynchronizationN timing out... TODO: This is extremely ugly, clean this up instead :/