From f2ade343e2492c213ac93680a55e9bed712dac9a Mon Sep 17 00:00:00 2001
From: Fernando Sahmkow <fsahmkow27@gmail.com>
Date: Thu, 19 Mar 2020 13:09:32 -0400
Subject: SingleCore: Move Host Timing from a sepparate thread to main cpu
 thread.

---
 src/core/core_timing.cpp | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

(limited to 'src/core/core_timing.cpp')

diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 3438f79cee..189d4aa34d 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -55,7 +55,9 @@ void CoreTiming::Initialize(std::function<void(void)>&& on_thread_init_) {
     event_fifo_id = 0;
     const auto empty_timed_callback = [](u64, s64) {};
     ev_lost = CreateEvent("_lost_event", empty_timed_callback);
-    timer_thread = std::make_unique<std::thread>(ThreadEntry, std::ref(*this));
+    if (is_multicore) {
+        timer_thread = std::make_unique<std::thread>(ThreadEntry, std::ref(*this));
+    }
 }
 
 void CoreTiming::Shutdown() {
@@ -63,7 +65,9 @@ void CoreTiming::Shutdown() {
     shutting_down = true;
     pause_event.Set();
     event.Set();
-    timer_thread->join();
+    if (timer_thread) {
+        timer_thread->join();
+    }
     ClearPendingEvents();
     timer_thread.reset();
     has_started = false;
@@ -78,12 +82,14 @@ void CoreTiming::SyncPause(bool is_paused) {
         return;
     }
     Pause(is_paused);
-    if (!is_paused) {
-        pause_event.Set();
+    if (timer_thread) {
+        if (!is_paused) {
+            pause_event.Set();
+        }
+        event.Set();
+        while (paused_set != is_paused)
+            ;
     }
-    event.Set();
-    while (paused_set != is_paused)
-        ;
 }
 
 bool CoreTiming::IsRunning() const {
-- 
cgit v1.2.3-70-g09d2