summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2015-05-19 00:49:51 +0200
committerbunnei <bunneidev@gmail.com>2015-05-19 00:49:51 +0200
commit1c3cda5d7e94afd0a74525beb1e0798aa8b79dec (patch)
tree8b1d7d4d2b7b2c242bad6eb277f8b1e01491ebe0 /src
parentMerge pull request #766 from purpasmart96/cfg_service_update (diff)
parentUse condition var to properly pause the CPU thread (diff)
downloadyuzu-1c3cda5d7e94afd0a74525beb1e0798aa8b79dec.tar
yuzu-1c3cda5d7e94afd0a74525beb1e0798aa8b79dec.tar.gz
yuzu-1c3cda5d7e94afd0a74525beb1e0798aa8b79dec.tar.bz2
yuzu-1c3cda5d7e94afd0a74525beb1e0798aa8b79dec.tar.lz
yuzu-1c3cda5d7e94afd0a74525beb1e0798aa8b79dec.tar.xz
yuzu-1c3cda5d7e94afd0a74525beb1e0798aa8b79dec.tar.zst
yuzu-1c3cda5d7e94afd0a74525beb1e0798aa8b79dec.zip
Diffstat (limited to 'src')
-rw-r--r--src/citra_qt/bootmanager.cpp3
-rw-r--r--src/citra_qt/bootmanager.h13
2 files changed, 14 insertions, 2 deletions
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index d3df289f8..ab9403007 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -59,6 +59,9 @@ void EmuThread::run() {
yieldCurrentThread();
was_active = false;
+ } else {
+ std::unique_lock<std::mutex> lock(running_mutex);
+ running_cv.wait(lock, [this]{ return IsRunning() || stop_run; });
}
}
diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h
index d5d74c949..16809eaae 100644
--- a/src/citra_qt/bootmanager.h
+++ b/src/citra_qt/bootmanager.h
@@ -3,6 +3,8 @@
// Refer to the license.txt file included.
#include <atomic>
+#include <condition_variable>
+#include <mutex>
#include <QThread>
#include <QGLWidget>
@@ -40,7 +42,12 @@ public:
* @param running Boolean value, set the emulation thread to running if true
* @note This function is thread-safe
*/
- void SetRunning(bool running) { this->running = running; }
+ void SetRunning(bool running) {
+ std::unique_lock<std::mutex> lock(running_mutex);
+ this->running = running;
+ lock.unlock();
+ running_cv.notify_all();
+ }
/**
* Check if the emulation thread is running or not
@@ -54,13 +61,15 @@ public:
*/
void RequestStop() {
stop_run = true;
- running = false;
+ SetRunning(false);
};
private:
bool exec_step;
bool running;
std::atomic<bool> stop_run;
+ std::mutex running_mutex;
+ std::condition_variable running_cv;
GRenderWindow* render_window;