1515#endif
1616#include " Emu/Io/PadHandler.h"
1717#include " Emu/system_config.h"
18- #include " Utilities/Thread.h"
1918#include " rpcs3qt/gui_settings.h"
2019
2120#ifdef __linux__
@@ -43,16 +42,16 @@ atomic_t<bool> gui_pad_thread::m_reset = false;
4342
4443gui_pad_thread::gui_pad_thread ()
4544{
46- m_thread = std::make_unique<std::thread>(&gui_pad_thread::run, this );
45+ m_thread = std::make_unique<named_thread< std::function< void ()>>>( " Gui Pad Thread " , [ this ](){ run (); } );
4746}
4847
4948gui_pad_thread::~gui_pad_thread ()
5049{
51- m_terminate = true ;
52-
53- if (m_thread && m_thread->joinable ())
50+ if (m_thread)
5451 {
55- m_thread->join ();
52+ auto & thread = *m_thread;
53+ thread = thread_state::aborting;
54+ thread ();
5655 m_thread.reset ();
5756 }
5857
@@ -253,13 +252,11 @@ void gui_pad_thread::InitPadConfig(cfg_pad& cfg, pad_handler type, std::shared_p
253252
254253void gui_pad_thread::run ()
255254{
256- thread_base::set_name (" Gui Pad Thread" );
257-
258255 gui_log.notice (" gui_pad_thread: Pad thread started" );
259256
260257 m_reset = true ;
261258
262- while (!m_terminate )
259+ while (thread_ctrl::state () != thread_state::aborting )
263260 {
264261 if (m_reset && m_reset.exchange (false ))
265262 {
@@ -275,20 +272,15 @@ void gui_pad_thread::run()
275272 {
276273 m_handler->process ();
277274
278- if (m_terminate )
275+ if (thread_ctrl::state () == thread_state::aborting )
279276 {
280277 break ;
281278 }
282279
283280 process_input ();
284281 }
285282
286- if (m_terminate)
287- {
288- break ;
289- }
290-
291- std::this_thread::sleep_for (10ms);
283+ thread_ctrl::wait_for (10000 );
292284 }
293285
294286 gui_log.notice (" gui_pad_thread: Pad thread stopped" );
0 commit comments