mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-19 19:15:26 +00:00
Use named_thread in gui_pad_thread
This commit is contained in:
parent
3737cc37f6
commit
e577362efb
2 changed files with 10 additions and 20 deletions
|
@ -15,7 +15,6 @@
|
|||
#endif
|
||||
#include "Emu/Io/PadHandler.h"
|
||||
#include "Emu/system_config.h"
|
||||
#include "Utilities/Thread.h"
|
||||
#include "rpcs3qt/gui_settings.h"
|
||||
|
||||
#ifdef __linux__
|
||||
|
@ -43,16 +42,16 @@ atomic_t<bool> gui_pad_thread::m_reset = false;
|
|||
|
||||
gui_pad_thread::gui_pad_thread()
|
||||
{
|
||||
m_thread = std::make_unique<std::thread>(&gui_pad_thread::run, this);
|
||||
m_thread = std::make_unique<named_thread<std::function<void()>>>("Gui Pad Thread", [this](){ run(); });
|
||||
}
|
||||
|
||||
gui_pad_thread::~gui_pad_thread()
|
||||
{
|
||||
m_terminate = true;
|
||||
|
||||
if (m_thread && m_thread->joinable())
|
||||
if (m_thread)
|
||||
{
|
||||
m_thread->join();
|
||||
auto& thread = *m_thread;
|
||||
thread = thread_state::aborting;
|
||||
thread();
|
||||
m_thread.reset();
|
||||
}
|
||||
|
||||
|
@ -253,13 +252,11 @@ void gui_pad_thread::InitPadConfig(cfg_pad& cfg, pad_handler type, std::shared_p
|
|||
|
||||
void gui_pad_thread::run()
|
||||
{
|
||||
thread_base::set_name("Gui Pad Thread");
|
||||
|
||||
gui_log.notice("gui_pad_thread: Pad thread started");
|
||||
|
||||
m_reset = true;
|
||||
|
||||
while (!m_terminate)
|
||||
while (thread_ctrl::state() != thread_state::aborting)
|
||||
{
|
||||
if (m_reset && m_reset.exchange(false))
|
||||
{
|
||||
|
@ -275,7 +272,7 @@ void gui_pad_thread::run()
|
|||
{
|
||||
m_handler->process();
|
||||
|
||||
if (m_terminate)
|
||||
if (thread_ctrl::state() == thread_state::aborting)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -283,12 +280,7 @@ void gui_pad_thread::run()
|
|||
process_input();
|
||||
}
|
||||
|
||||
if (m_terminate)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(10ms);
|
||||
thread_ctrl::wait_for(10000);
|
||||
}
|
||||
|
||||
gui_log.notice("gui_pad_thread: Pad thread stopped");
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
#include "Emu/Io/pad_config.h"
|
||||
#include "Emu/Io/pad_config_types.h"
|
||||
#include "Utilities/Timer.h"
|
||||
|
||||
#include <thread>
|
||||
#include "Utilities/Thread.h"
|
||||
|
||||
class PadHandlerBase;
|
||||
class gui_settings;
|
||||
|
@ -62,8 +61,7 @@ protected:
|
|||
std::shared_ptr<PadHandlerBase> m_handler;
|
||||
std::shared_ptr<Pad> m_pad;
|
||||
|
||||
std::unique_ptr<std::thread> m_thread;
|
||||
atomic_t<bool> m_terminate = false;
|
||||
std::unique_ptr<named_thread<std::function<void()>>> m_thread;
|
||||
atomic_t<bool> m_allow_global_input = false;
|
||||
static atomic_t<bool> m_reset;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue