Stop using std::jthread, because Mac doesn't support it

This commit is contained in:
capitalistspz 2024-09-26 21:37:12 +01:00
parent ae2f5d23b3
commit d52405935f
2 changed files with 6 additions and 5 deletions

View File

@ -16,7 +16,7 @@ WiimoteControllerProvider::WiimoteControllerProvider()
{
m_reader_thread = std::thread(&WiimoteControllerProvider::reader_thread, this);
m_writer_thread = std::thread(&WiimoteControllerProvider::writer_thread, this);
m_connectionThread = std::jthread(&WiimoteControllerProvider::connectionThread, this);
m_connectionThread = std::thread(&WiimoteControllerProvider::connectionThread, this);
}
WiimoteControllerProvider::~WiimoteControllerProvider()
@ -26,6 +26,7 @@ WiimoteControllerProvider::~WiimoteControllerProvider()
m_running = false;
m_writer_thread.join();
m_reader_thread.join();
m_connectionThread.join();
}
}
@ -143,10 +144,10 @@ WiimoteControllerProvider::WiimoteState WiimoteControllerProvider::get_state(siz
return {};
}
void WiimoteControllerProvider::connectionThread(std::stop_token stopToken)
void WiimoteControllerProvider::connectionThread()
{
SetThreadName("Wiimote-connect");
while (!stopToken.stop_requested())
while (m_running.load(std::memory_order_relaxed))
{
std::vector<WiimoteDevicePtr> devices;
#if HAS_HIDAPI

View File

@ -79,7 +79,7 @@ private:
std::thread m_reader_thread, m_writer_thread;
std::shared_mutex m_device_mutex;
std::jthread m_connectionThread;
std::thread m_connectionThread;
std::vector<WiimoteDevicePtr> m_connectedDevices;
std::mutex m_connectedDeviceMutex;
struct Wiimote
@ -104,7 +104,7 @@ private:
void reader_thread();
void writer_thread();
void connectionThread(std::stop_token);
void connectionThread();
void calibrate(size_t index);
IRMode set_ir_camera(size_t index, bool state);