semaphore: Yet another race condition fix (#327)

This commit is contained in:
TheTurtle 2024-07-27 17:18:18 +03:00 committed by GitHub
parent b7c3ff932b
commit d84b4adc83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 4 deletions

View File

@ -41,7 +41,6 @@ public:
AddWaiter(waiter);
// Perform the wait.
std::exchange(lk, std::unique_lock{waiter.mutex});
return waiter.Wait(lk, timeout);
}
@ -59,10 +58,9 @@ public:
it++;
continue;
}
std::scoped_lock lk2{waiter.mutex};
it = wait_list.erase(it);
token_count -= waiter.need_count;
waiter.cv.notify_one();
it = wait_list.erase(it);
}
return true;
@ -84,7 +82,6 @@ public:
public:
struct WaitingThread : public ListBaseHook {
std::mutex mutex;
std::string name;
std::condition_variable cv;
u32 priority;