mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
Improve thread aborting mechanism (#10490)
Call pseudo-virtual operator=(thread_state) of thread context.
This commit is contained in:
parent
58847fa2ca
commit
0aed00a758
7 changed files with 31 additions and 44 deletions
|
@ -35,8 +35,6 @@ enum class thread_state : u32
|
|||
mask = 3
|
||||
};
|
||||
|
||||
class need_wakeup {};
|
||||
|
||||
template <class Context>
|
||||
class named_thread;
|
||||
|
||||
|
@ -616,14 +614,14 @@ public:
|
|||
// Join thread by thread_state::finished
|
||||
named_thread& operator=(thread_state s)
|
||||
{
|
||||
if constexpr (std::is_assignable_v<Context&, thread_state>)
|
||||
{
|
||||
static_cast<Context&>(*this) = s;
|
||||
}
|
||||
|
||||
if (s >= thread_state::aborting && thread::m_sync.fetch_op([](u64& v){ return !(v & 3) && (v |= 1); }).second)
|
||||
{
|
||||
thread::m_sync.notify_one(1);
|
||||
|
||||
if constexpr (std::is_base_of_v<need_wakeup, Context>)
|
||||
{
|
||||
this->wake_up();
|
||||
}
|
||||
}
|
||||
|
||||
if (s == thread_state::finished)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue