1
0
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:
Ivan Savenko
2025-03-01 21:47:53 +00:00
parent 0536c55b9d
commit 3d205e0291
3 changed files with 5 additions and 127 deletions

View File

@ -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()