mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Remove custom implementation of threadpool from rmg in favor of TBB
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
#include "Zone.h"
|
||||
#include "Functions.h"
|
||||
#include "RmgMap.h"
|
||||
#include "threadpool/ThreadPool.h"
|
||||
#include "modificators/ObjectManager.h"
|
||||
#include "modificators/TreasurePlacer.h"
|
||||
#include "modificators/RoadPlacer.h"
|
||||
@@ -37,6 +36,8 @@
|
||||
#include <vstd/RNG.h>
|
||||
#include <vcmi/HeroTypeService.h>
|
||||
|
||||
#include <tbb/task_group.h>
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
CMapGenerator::CMapGenerator(CMapGenOptions& mapGenOptions, IGameCallback * cb, int RandomSeed) :
|
||||
@@ -395,10 +396,7 @@ void CMapGenerator::fillZones()
|
||||
}
|
||||
else
|
||||
{
|
||||
ThreadPool pool;
|
||||
std::vector<boost::future<void>> futures;
|
||||
//At most one Modificator can run for every zone
|
||||
pool.init(std::min<int>(boost::thread::hardware_concurrency(), numZones));
|
||||
tbb::task_group pool;
|
||||
|
||||
while (!allJobs.empty())
|
||||
{
|
||||
@@ -412,12 +410,12 @@ void CMapGenerator::fillZones()
|
||||
else if ((*it)->isReady())
|
||||
{
|
||||
auto jobCopy = *it;
|
||||
futures.emplace_back(pool.async([this, jobCopy]() -> void
|
||||
pool.run([this, jobCopy]() -> void
|
||||
{
|
||||
jobCopy->run();
|
||||
Progress::Progress::step(); //Update progress bar
|
||||
}
|
||||
));
|
||||
);
|
||||
it = allJobs.erase(it);
|
||||
}
|
||||
else
|
||||
@@ -428,10 +426,7 @@ void CMapGenerator::fillZones()
|
||||
}
|
||||
|
||||
//Wait for all the tasks
|
||||
for (auto& fut : futures)
|
||||
{
|
||||
fut.get();
|
||||
}
|
||||
pool.wait();
|
||||
}
|
||||
|
||||
for (const auto& it : map->getZones())
|
||||
|
||||
Reference in New Issue
Block a user