mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Remove no longer needed synchronization that also fails to compile.
This commit is contained in:
@@ -66,28 +66,6 @@ protected:
|
|||||||
using RecursiveLock = boost::unique_lock<boost::recursive_mutex>;
|
using RecursiveLock = boost::unique_lock<boost::recursive_mutex>;
|
||||||
using Lock = boost::unique_lock<boost::shared_mutex>;
|
using Lock = boost::unique_lock<boost::shared_mutex>;
|
||||||
|
|
||||||
template <typename TModificator>
|
|
||||||
std::vector<RecursiveLock> tryLockAll()
|
|
||||||
{
|
|
||||||
std::vector<RecursiveLock> locks;
|
|
||||||
for (auto & zone : map.getZones())
|
|
||||||
{
|
|
||||||
if (auto * m = zone.second->getModificator<TModificator>())
|
|
||||||
{
|
|
||||||
RecursiveLock lock(m->externalAccessMutex, boost::try_to_lock_t{});
|
|
||||||
if (lock.owns_lock())
|
|
||||||
{
|
|
||||||
locks.emplace_back(std::move(lock));
|
|
||||||
}
|
|
||||||
else //return empty
|
|
||||||
{
|
|
||||||
return std::vector<RecursiveLock>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return locks;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void process() = 0;
|
virtual void process() = 0;
|
||||||
|
|
||||||
|
@@ -27,22 +27,8 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|||||||
|
|
||||||
void ObjectDistributor::process()
|
void ObjectDistributor::process()
|
||||||
{
|
{
|
||||||
//Do that only once
|
distributeLimitedObjects();
|
||||||
auto lockVec = tryLockAll<ObjectDistributor>();
|
distributeSeerHuts();
|
||||||
if (!lockVec.empty())
|
|
||||||
{
|
|
||||||
for(auto & z : map.getZones())
|
|
||||||
{
|
|
||||||
if(auto * m = z.second->getModificator<ObjectDistributor>())
|
|
||||||
{
|
|
||||||
if(m->isFinished())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
distributeLimitedObjects();
|
|
||||||
distributeSeerHuts();
|
|
||||||
finished = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectDistributor::init()
|
void ObjectDistributor::init()
|
||||||
|
@@ -30,22 +30,7 @@ class TileInfo;
|
|||||||
|
|
||||||
void RockFiller::process()
|
void RockFiller::process()
|
||||||
{
|
{
|
||||||
//Do that only once
|
processMap();
|
||||||
auto lockVec = tryLockAll<RockFiller>();
|
|
||||||
if (!lockVec.empty())
|
|
||||||
{
|
|
||||||
for(auto & z : map.getZones())
|
|
||||||
{
|
|
||||||
if(auto * m = z.second->getModificator<RockFiller>())
|
|
||||||
{
|
|
||||||
if(m->isFinished())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logGlobal->info("Processing RockFiller for the whole map");
|
|
||||||
processMap();
|
|
||||||
finished = true; //Block other placers immediately
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RockFiller::processMap()
|
void RockFiller::processMap()
|
||||||
|
Reference in New Issue
Block a user