mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
named_thread_group: add a default constructor
This commit is contained in:
parent
9db088e17b
commit
aae338a91c
@ -427,6 +427,11 @@ class named_thread_group final
|
||||
|
||||
Thread* m_threads;
|
||||
|
||||
void init_threads()
|
||||
{
|
||||
m_threads = static_cast<Thread*>(::operator new(sizeof(Thread) * m_count, std::align_val_t{alignof(Thread)}));
|
||||
}
|
||||
|
||||
public:
|
||||
// Lambda constructor, also the implicit deduction guide candidate
|
||||
named_thread_group(std::string_view name, u32 count, const Context& f)
|
||||
@ -438,7 +443,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
m_threads = static_cast<Thread*>(::operator new(sizeof(Thread) * m_count, std::align_val_t{alignof(Thread)}));
|
||||
init_threads();
|
||||
|
||||
// Create all threads
|
||||
for (u32 i = 0; i < m_count; i++)
|
||||
@ -447,6 +452,25 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Default constructor
|
||||
named_thread_group(std::string_view name, u32 count)
|
||||
: m_count(count)
|
||||
, m_threads(nullptr)
|
||||
{
|
||||
if (count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
init_threads();
|
||||
|
||||
// Create all threads
|
||||
for (u32 i = 0; i < m_count; i++)
|
||||
{
|
||||
new (static_cast<void*>(m_threads + i)) Thread(std::string(name) + std::to_string(i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
named_thread_group(const named_thread_group&) = delete;
|
||||
|
||||
named_thread_group& operator=(const named_thread_group&) = delete;
|
||||
|
Loading…
Reference in New Issue
Block a user