mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
named_thread: allow default constructor only with thread_name
In C++20, lambdas may be default-constructible allowing nasty stuff.
This commit is contained in:
parent
e102dc2a94
commit
a0d2bc9769
1 changed files with 2 additions and 14 deletions
|
@ -361,26 +361,14 @@ class named_thread final : public Context, result_storage_t<Context>, thread_bas
|
|||
return thread::finalize(0);
|
||||
}
|
||||
|
||||
static decltype(auto) get_default_thread_name()
|
||||
{
|
||||
if constexpr (thread_thread_name<Context>())
|
||||
{
|
||||
return Context::thread_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Unnamed Thread";
|
||||
}
|
||||
}
|
||||
|
||||
friend class thread_ctrl;
|
||||
|
||||
public:
|
||||
// Default constructor
|
||||
template <bool Valid = std::is_default_constructible_v<Context>, typename = std::enable_if_t<Valid>>
|
||||
template <bool Valid = std::is_default_constructible_v<Context> && thread_thread_name<Context>(), typename = std::enable_if_t<Valid>>
|
||||
named_thread()
|
||||
: Context()
|
||||
, thread(get_default_thread_name())
|
||||
, thread(Context::thread_name)
|
||||
{
|
||||
thread::start(&named_thread::entry_point);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue