mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Fix misuses of cond.wait (should return true when you want to stop waiting!)
This commit is contained in:
1 parent
5b20ace502
commit
bde54ccdc0
3 files changed
+13
-8
No files matched your search
@@ -7,12 +7,15 @@
|
||||
|
||||
struct Event : public Waitable {
|
||||
public:
|
||||
Event() {
|
||||
triggered_ = false;
|
||||
}
|
||||
|
||||
void Wait() override {
|
||||
if (triggered_) {
|
||||
return;
|
||||
if (!triggered_) {
|
||||
std::unique_lock<std::mutex> lock;
|
||||
cond_.wait(lock, [&] { return triggered_.load(); });
|
||||
}
|
||||
std::unique_lock<std::mutex> lock;
|
||||
cond_.wait(lock, [&] { return !triggered_; });
|
||||
}
|
||||
|
||||
void Notify() {
|
||||
@@ -24,5 +27,5 @@ public:
|
||||
private:
|
||||
std::condition_variable cond_;
|
||||
std::mutex mutex_;
|
||||
bool triggered_ = false;
|
||||
std::atomic<bool> triggered_;
|
||||
};
|
||||
Reference in new issue
Block a user