mirror of
https://github.com/PabloMK7/citra.git
synced 2024-12-28 18:46:11 +00:00
Port yuzu-emu/yuzu#4587 and yuzu-emu/yuzu#4588: Fix data races (#5545)
Co-authored-by: ReinUsesLisp <reinuseslisp@airmail.cc>
This commit is contained in:
parent
df9e230d63
commit
017631e51b
2
externals/microprofile/microprofile.h
vendored
2
externals/microprofile/microprofile.h
vendored
|
@ -1018,7 +1018,7 @@ static void MicroProfileCreateThreadLogKey()
|
|||
#else
|
||||
MP_THREAD_LOCAL MicroProfileThreadLog* g_MicroProfileThreadLog = 0;
|
||||
#endif
|
||||
static bool g_bUseLock = false; /// This is used because windows does not support using mutexes under dll init(which is where global initialization is handled)
|
||||
static std::atomic<bool> g_bUseLock{false}; /// This is used because windows does not support using mutexes under dll init(which is where global initialization is handled)
|
||||
|
||||
|
||||
MICROPROFILE_DEFINE(g_MicroProfileFlip, "MicroProfile", "MicroProfileFlip", 0x3355ee);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <cstddef>
|
||||
|
@ -24,14 +25,14 @@ public:
|
|||
|
||||
void Wait() {
|
||||
std::unique_lock lk{mutex};
|
||||
condvar.wait(lk, [&] { return is_set; });
|
||||
condvar.wait(lk, [&] { return is_set.load(); });
|
||||
is_set = false;
|
||||
}
|
||||
|
||||
template <class Duration>
|
||||
bool WaitFor(const std::chrono::duration<Duration>& time) {
|
||||
std::unique_lock lk{mutex};
|
||||
if (!condvar.wait_for(lk, time, [this] { return is_set; }))
|
||||
if (!condvar.wait_for(lk, time, [this] { return is_set.load(); }))
|
||||
return false;
|
||||
is_set = false;
|
||||
return true;
|
||||
|
@ -40,7 +41,7 @@ public:
|
|||
template <class Clock, class Duration>
|
||||
bool WaitUntil(const std::chrono::time_point<Clock, Duration>& time) {
|
||||
std::unique_lock lk{mutex};
|
||||
if (!condvar.wait_until(lk, time, [this] { return is_set; }))
|
||||
if (!condvar.wait_until(lk, time, [this] { return is_set.load(); }))
|
||||
return false;
|
||||
is_set = false;
|
||||
return true;
|
||||
|
@ -54,9 +55,9 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
bool is_set = false;
|
||||
std::condition_variable condvar;
|
||||
std::mutex mutex;
|
||||
std::atomic_bool is_set{false};
|
||||
};
|
||||
|
||||
class Barrier {
|
||||
|
|
Loading…
Reference in a new issue