mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 21:38:01 +03:00
named_thread_group: add a default constructor
This commit is contained in:
parent
9db088e17b
commit
aae338a91c
1 changed files with 25 additions and 1 deletions
|
@ -427,6 +427,11 @@ class named_thread_group final
|
||||||
|
|
||||||
Thread* m_threads;
|
Thread* m_threads;
|
||||||
|
|
||||||
|
void init_threads()
|
||||||
|
{
|
||||||
|
m_threads = static_cast<Thread*>(::operator new(sizeof(Thread) * m_count, std::align_val_t{alignof(Thread)}));
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Lambda constructor, also the implicit deduction guide candidate
|
// Lambda constructor, also the implicit deduction guide candidate
|
||||||
named_thread_group(std::string_view name, u32 count, const Context& f)
|
named_thread_group(std::string_view name, u32 count, const Context& f)
|
||||||
|
@ -438,7 +443,7 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_threads = static_cast<Thread*>(::operator new(sizeof(Thread) * m_count, std::align_val_t{alignof(Thread)}));
|
init_threads();
|
||||||
|
|
||||||
// Create all threads
|
// Create all threads
|
||||||
for (u32 i = 0; i < m_count; i++)
|
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(const named_thread_group&) = delete;
|
||||||
|
|
||||||
named_thread_group& operator=(const named_thread_group&) = delete;
|
named_thread_group& operator=(const named_thread_group&) = delete;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue