Skip to content

Commit d7acafc

Browse files
committed
Add early termination for gui_pad_thread
1 parent 7cb2977 commit d7acafc

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

rpcs3/Input/gui_pad_thread.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,18 @@ gui_pad_thread::gui_pad_thread()
4545
m_thread = std::make_unique<named_thread<std::function<void()>>>("Gui Pad Thread", [this](){ run(); });
4646
}
4747

48-
gui_pad_thread::~gui_pad_thread()
48+
gui_pad_thread& gui_pad_thread::operator=(thread_state state) const noexcept
4949
{
50+
if (state == thread_state::aborting)
51+
{
52+
if (m_thread)
53+
{
54+
*m_thread = state;
55+
}
56+
57+
return *this;
58+
}
59+
5060
// Join thread
5161
m_thread.reset();
5262

@@ -63,6 +73,18 @@ gui_pad_thread::~gui_pad_thread()
6373
m_uinput_fd = -1;
6474
}
6575
#endif
76+
77+
return *this;
78+
}
79+
80+
gui_pad_thread::operator thread_state() const noexcept
81+
{
82+
return m_thread && *m_thread != thread_state::finished ? m_thread->operator thread_state() : thread_state::finished;
83+
}
84+
85+
gui_pad_thread::~gui_pad_thread()
86+
{
87+
*this = thread_state::finished;
6688
}
6789

6890
void gui_pad_thread::update_settings(const std::shared_ptr<gui_settings>& settings)

rpcs3/Input/gui_pad_thread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class gui_pad_thread
1515
{
1616
public:
1717
gui_pad_thread();
18+
gui_pad_thread& operator=(thread_state state) const noexcept;
19+
operator thread_state() const noexcept;
1820
virtual ~gui_pad_thread();
1921

2022
void update_settings(const std::shared_ptr<gui_settings>& settings);

0 commit comments

Comments
 (0)