1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +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

@@ -13,6 +13,8 @@
#include "../../../CCallback.h"
#include "../../../lib/mapping/CMapDefines.h"
#include <tbb/task_group.h>
std::vector<std::shared_ptr<AINodeStorage>> AIPathfinder::storagePool;
std::map<HeroPtr, std::shared_ptr<AINodeStorage>> AIPathfinder::storageMap;
@@ -60,7 +62,7 @@ void AIPathfinder::updatePaths(std::vector<HeroPtr> heroes)
cb->calculatePaths(config);
};
std::vector<CThreadHelper::Task> calculationTasks;
tbb::task_group calculationTasks;
for(HeroPtr hero : heroes)
{
@@ -81,26 +83,10 @@ void AIPathfinder::updatePaths(std::vector<HeroPtr> heroes)
auto config = std::make_shared<AIPathfinding::AIPathfinderConfig>(cb, ai, nodeStorage);
calculationTasks.push_back(std::bind(calculatePaths, hero.get(), config));
calculationTasks.run(std::bind(calculatePaths, hero.get(), config));
}
int threadsCount = std::min(
boost::thread::hardware_concurrency(),
(uint32_t)calculationTasks.size());
if(threadsCount <= 1)
{
for(auto task : calculationTasks)
{
task();
}
}
else
{
CThreadHelper helper(&calculationTasks, threadsCount);
helper.run();
}
calculationTasks.wait();
}
std::shared_ptr<const AINodeStorage> AIPathfinder::getStorage(const HeroPtr & hero) const