Qt: Restructured to remove unnecessary shutdown event and various cleanups.

This commit is contained in:
bunnei 2015-04-28 19:03:01 -04:00
parent 3dd2688785
commit e4ea133717
4 changed files with 40 additions and 90 deletions

View file

@ -25,66 +25,46 @@ public:
/**
* Start emulation (on new thread)
*
* @warning Only call when not running!
*/
void run() override;
/**
* Allow the CPU to process a single instruction (if cpu is not running)
*
* Steps the emulation thread by a single CPU instruction (if the CPU is not already running)
* @note This function is thread-safe
*/
void ExecStep() { exec_cpu_step = true; }
void ExecStep() { exec_step = true; }
/**
* Sets whether the CPU is running
*
* Sets whether the emulation thread is running or not
* @param running Boolean value, set the emulation thread to running if true
* @note This function is thread-safe
*/
void SetCpuRunning(bool running) { cpu_running = running; }
void SetRunning(bool running) { this->running = running; }
/**
* Allow the CPU to continue processing instructions without interruption
*
* Check if the emulation thread is running or not
* @return True if the emulation thread is running, otherwise false
* @note This function is thread-safe
*/
bool IsCpuRunning() { return cpu_running; }
bool IsRunning() { return running; }
/**
* Shutdown (permantently stops) the CPU
* Shutdown (permanently stops) the emulation thread
*/
void ShutdownCpu() { stop_run = true; };
/**
* Waits for the CPU shutdown to complete
*/
void WaitForCpuShutdown() { shutdown_event.Wait(); }
public slots:
/**
* Stop emulation and wait for the thread to finish.
*
* @details: This function will wait a second for the thread to finish; if it hasn't finished until then, we'll terminate() it and wait another second, hoping that it will be terminated by then.
* @note: This function is thread-safe.
*/
void Stop();
void Shutdown() { stop_run = true; };
private:
friend class GMainWindow;
EmuThread(GRenderWindow* render_window);
bool exec_cpu_step;
bool cpu_running;
bool exec_step;
bool running;
std::atomic<bool> stop_run;
GRenderWindow* render_window;
Common::Event shutdown_event;
signals:
/**
* Emitted when the CPU has halted execution