mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Fix race condition in LimitedWaitable between Notify and Wait
This commit is contained in:
1 parent
bde54ccdc0
commit
adfce57d9e
2 files changed
+3
-3
No files matched your search
@@ -12,8 +12,8 @@ public:
|
||||
}
|
||||
|
||||
void Wait() override {
|
||||
std::unique_lock<std::mutex> lock;
|
||||
if (!triggered_) {
|
||||
std::unique_lock<std::mutex> lock;
|
||||
cond_.wait(lock, [&] { return triggered_.load(); });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,18 +12,18 @@ public:
|
||||
}
|
||||
|
||||
void Wait() override {
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
if (!triggered_) {
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
cond_.wait(lock, [&] { return triggered_.load(); });
|
||||
}
|
||||
}
|
||||
|
||||
bool WaitFor(double budget) {
|
||||
uint32_t us = budget > 0 ? (uint32_t)(budget * 1000000.0) : 0;
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
if (!triggered_) {
|
||||
if (us == 0)
|
||||
return false;
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
cond_.wait_for(lock, std::chrono::microseconds(us), [&] { return triggered_.load(); });
|
||||
}
|
||||
return triggered_;
|
||||
|
||||
Reference in new issue
Block a user