|
|
@ -3,6 +3,8 @@ |
|
|
// Refer to the license.txt file included. |
|
|
// Refer to the license.txt file included. |
|
|
|
|
|
|
|
|
#include <atomic> |
|
|
#include <atomic> |
|
|
|
|
|
#include <condition_variable> |
|
|
|
|
|
#include <mutex> |
|
|
|
|
|
|
|
|
#include <QThread> |
|
|
#include <QThread> |
|
|
#include <QGLWidget> |
|
|
#include <QGLWidget> |
|
|
@ -40,7 +42,12 @@ public: |
|
|
* @param running Boolean value, set the emulation thread to running if true |
|
|
* @param running Boolean value, set the emulation thread to running if true |
|
|
* @note This function is thread-safe |
|
|
* @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 |
|
|
* Check if the emulation thread is running or not |
|
|
@ -54,13 +61,15 @@ public: |
|
|
*/ |
|
|
*/ |
|
|
void RequestStop() { |
|
|
void RequestStop() { |
|
|
stop_run = true; |
|
|
stop_run = true; |
|
|
running = false; |
|
|
|
|
|
|
|
|
SetRunning(false); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
bool exec_step; |
|
|
bool exec_step; |
|
|
bool running; |
|
|
bool running; |
|
|
std::atomic<bool> stop_run; |
|
|
std::atomic<bool> stop_run; |
|
|
|
|
|
std::mutex running_mutex; |
|
|
|
|
|
std::condition_variable running_cv; |
|
|
|
|
|
|
|
|
GRenderWindow* render_window; |
|
|
GRenderWindow* render_window; |
|
|
|
|
|
|
|
|
|