summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2013-09-04 05:30:16 -0400
committercomex <comexk@gmail.com>2013-09-04 05:32:32 -0400
commit8992f587202529a94ee9e2fa3c1a01d10ea1c691 (patch)
treea2c9d0c426da5dafc77dd0eae3f1cd18b92c9078 /Source/Core
parentdc87b6d43196537842bc37d1bd6f3f28f911dd36 (diff)
Fix Wiimote thread wakeup on externally-triggered destroy.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp5
-rw-r--r--Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h6
2 files changed, 9 insertions, 2 deletions
diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
index 6cb9521981..77f84449be 100644
--- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
+++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
@@ -503,11 +503,14 @@ bool Wiimote::Connect()
void Wiimote::StartThread()
{
+ m_run_thread = true;
m_wiimote_thread = std::thread(std::mem_fun(&Wiimote::ThreadFunc), this);
}
void Wiimote::StopThread()
{
+ m_run_thread = false;
+ IOWakeup();
if (m_wiimote_thread.joinable())
m_wiimote_thread.join();
#if defined(__APPLE__)
@@ -554,7 +557,7 @@ void Wiimote::ThreadFunc()
}
// main loop
- while (IsConnected())
+ while (IsConnected() && m_run_thread)
{
if (m_need_prepare)
{
diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
index 314fb2e83c..fa94303a66 100644
--- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
+++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
@@ -113,8 +113,12 @@ private:
bool m_rumble_state;
std::thread m_wiimote_thread;
- volatile bool m_thread_ready;
+ // Whether to keep running the thread.
+ volatile bool m_run_thread;
+ // Whether to call PrepareOnThread.
volatile bool m_need_prepare;
+ // Whether the thread has finished ConnectInternal.
+ volatile bool m_thread_ready;
std::mutex m_thread_ready_mutex;
std::condition_variable m_thread_ready_cond;