mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 05:51:27 +12: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);
|
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;
|
friend class thread_ctrl;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Default constructor
|
// 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()
|
named_thread()
|
||||||
: Context()
|
: Context()
|
||||||
, thread(get_default_thread_name())
|
, thread(Context::thread_name)
|
||||||
{
|
{
|
||||||
thread::start(&named_thread::entry_point);
|
thread::start(&named_thread::entry_point);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue