mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-17 00:07:41 +02:00
Remove CThreadHelper class, final usage replaced with tbb
This commit is contained in:
@ -21,40 +21,6 @@
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
CThreadHelper::CThreadHelper(std::vector<std::function<void()>> * Tasks, int Threads):
|
||||
currentTask(0),
|
||||
amount(static_cast<int>(Tasks->size())),
|
||||
tasks(Tasks),
|
||||
threads(Threads)
|
||||
{
|
||||
}
|
||||
void CThreadHelper::run()
|
||||
{
|
||||
std::vector<boost::thread> group;
|
||||
for(int i=0;i<threads;i++)
|
||||
group.emplace_back(std::bind(&CThreadHelper::processTasks,this));
|
||||
|
||||
for (auto & thread : group)
|
||||
thread.join();
|
||||
|
||||
//thread group deletes threads, do not free manually
|
||||
}
|
||||
void CThreadHelper::processTasks()
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
int pom;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(rtinm);
|
||||
if((pom = currentTask) >= amount)
|
||||
break;
|
||||
else
|
||||
++currentTask;
|
||||
}
|
||||
(*tasks)[pom]();
|
||||
}
|
||||
}
|
||||
|
||||
static thread_local std::string threadNameForLogging;
|
||||
|
||||
std::string getThreadName()
|
||||
|
Reference in New Issue
Block a user