mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
replace boost locks with std
This commit is contained in:
@@ -836,7 +836,7 @@ void AIGateway::makeTurn()
|
||||
auto day = cb->getDate(Date::DAY);
|
||||
logAi->info("Player %d (%s) starting turn, day %d", playerID, playerID.toString(), day);
|
||||
|
||||
boost::shared_lock gsLock(CGameState::mutex);
|
||||
std::shared_lock gsLock(CGameState::mutex);
|
||||
setThreadName("AIGateway::makeTurn");
|
||||
|
||||
if(nullkiller->isOpenMap())
|
||||
@@ -1582,7 +1582,7 @@ void AIGateway::buildArmyIn(const CGTownInstance * t)
|
||||
void AIGateway::finish()
|
||||
{
|
||||
//we want to lock to avoid multiple threads from calling makingTurn->join() at same time
|
||||
boost::lock_guard<boost::mutex> multipleCleanupGuard(turnInterruptionMutex);
|
||||
boost::lock_guard<std::mutex> multipleCleanupGuard(turnInterruptionMutex);
|
||||
|
||||
if(makingTurn)
|
||||
{
|
||||
@@ -1598,7 +1598,7 @@ void AIGateway::requestActionASAP(std::function<void()> whatToDo)
|
||||
{
|
||||
setThreadName("AIGateway::requestActionASAP::whatToDo");
|
||||
SET_GLOBAL_STATE(this);
|
||||
boost::shared_lock gsLock(CGameState::mutex);
|
||||
std::shared_lock gsLock(CGameState::mutex);
|
||||
whatToDo();
|
||||
});
|
||||
|
||||
@@ -1670,7 +1670,7 @@ AIStatus::~AIStatus()
|
||||
|
||||
void AIStatus::setBattle(BattleState BS)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
LOG_TRACE_PARAMS(logAi, "battle state=%d", (int)BS);
|
||||
battle = BS;
|
||||
cv.notify_all();
|
||||
@@ -1678,7 +1678,7 @@ void AIStatus::setBattle(BattleState BS)
|
||||
|
||||
BattleState AIStatus::getBattle()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
return battle;
|
||||
}
|
||||
|
||||
@@ -1691,7 +1691,7 @@ void AIStatus::addQuery(QueryID ID, std::string description)
|
||||
}
|
||||
|
||||
assert(ID.getNum() >= 0);
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
|
||||
assert(!vstd::contains(remainingQueries, ID));
|
||||
|
||||
@@ -1703,7 +1703,7 @@ void AIStatus::addQuery(QueryID ID, std::string description)
|
||||
|
||||
void AIStatus::removeQuery(QueryID ID)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
assert(vstd::contains(remainingQueries, ID));
|
||||
|
||||
std::string description = remainingQueries[ID];
|
||||
@@ -1715,40 +1715,40 @@ void AIStatus::removeQuery(QueryID ID)
|
||||
|
||||
int AIStatus::getQueriesCount()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
return static_cast<int>(remainingQueries.size());
|
||||
}
|
||||
|
||||
void AIStatus::startedTurn()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
havingTurn = true;
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
void AIStatus::madeTurn()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
havingTurn = false;
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
void AIStatus::waitTillFree()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
while(battle != NO_BATTLE || !remainingQueries.empty() || !objectsBeingVisited.empty() || ongoingHeroMovement)
|
||||
cv.wait_for(lock, boost::chrono::milliseconds(10));
|
||||
cv.wait_for(lock, std::chrono::milliseconds(10));
|
||||
}
|
||||
|
||||
bool AIStatus::haveTurn()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
return havingTurn;
|
||||
}
|
||||
|
||||
void AIStatus::attemptedAnsweringQuery(QueryID queryID, int answerRequestID)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
assert(vstd::contains(remainingQueries, queryID));
|
||||
std::string description = remainingQueries[queryID];
|
||||
logAi->debug("Attempted answering query %d - %s. Request id=%d. Waiting for results...", queryID, description, answerRequestID);
|
||||
@@ -1775,7 +1775,7 @@ void AIStatus::receivedAnswerConfirmation(int answerRequestID, int result)
|
||||
|
||||
void AIStatus::heroVisit(const CGObjectInstance * obj, bool started)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
if(started)
|
||||
{
|
||||
objectsBeingVisited.push_back(obj);
|
||||
@@ -1793,14 +1793,14 @@ void AIStatus::heroVisit(const CGObjectInstance * obj, bool started)
|
||||
|
||||
void AIStatus::setMove(bool ongoing)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
ongoingHeroMovement = ongoing;
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
void AIStatus::setChannelProbing(bool ongoing)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
ongoingChannelProbing = ongoing;
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace NKAI
|
||||
|
||||
class AIStatus
|
||||
{
|
||||
boost::mutex mx;
|
||||
boost::condition_variable cv;
|
||||
std::mutex mx;
|
||||
std::condition_variable cv;
|
||||
|
||||
BattleState battle;
|
||||
std::map<QueryID, std::string> remainingQueries;
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
std::shared_ptr<CCallback> myCb;
|
||||
std::unique_ptr<boost::thread> makingTurn;
|
||||
private:
|
||||
boost::mutex turnInterruptionMutex;
|
||||
std::mutex turnInterruptionMutex;
|
||||
|
||||
public:
|
||||
ObjectInstanceID selectedObject;
|
||||
|
||||
@@ -259,13 +259,13 @@ public:
|
||||
|
||||
void add(std::unique_ptr<T> t)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(sync);
|
||||
boost::lock_guard<std::mutex> lock(sync);
|
||||
pool.push_back(std::move(t));
|
||||
}
|
||||
|
||||
ptr_type acquire()
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(sync);
|
||||
boost::lock_guard<std::mutex> lock(sync);
|
||||
bool poolIsEmpty = pool.empty();
|
||||
T * element = poolIsEmpty
|
||||
? elementFactory().release()
|
||||
@@ -294,7 +294,7 @@ private:
|
||||
std::vector<std::unique_ptr<T>> pool;
|
||||
std::function<std::unique_ptr<T>()> elementFactory;
|
||||
std::shared_ptr<SharedPool<T> *> instance_tracker;
|
||||
boost::mutex sync;
|
||||
std::mutex sync;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ HeroLockedReason Nullkiller::getHeroLockedReason(const CGHeroInstance * hero) co
|
||||
|
||||
void Nullkiller::makeTurn()
|
||||
{
|
||||
boost::lock_guard<boost::mutex> sharedStorageLock(AISharedStorage::locker);
|
||||
boost::lock_guard<std::mutex> sharedStorageLock(AISharedStorage::locker);
|
||||
|
||||
const int MAX_DEPTH = 10;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace NKAI
|
||||
|
||||
std::shared_ptr<boost::multi_array<AIPathNode, 4>> AISharedStorage::shared;
|
||||
uint32_t AISharedStorage::version = 0;
|
||||
boost::mutex AISharedStorage::locker;
|
||||
std::mutex AISharedStorage::locker;
|
||||
std::set<int3> committedTiles;
|
||||
std::set<int3> committedTilesInitial;
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class AISharedStorage
|
||||
static std::shared_ptr<boost::multi_array<AIPathNode, 4>> shared;
|
||||
std::shared_ptr<boost::multi_array<AIPathNode, 4>> nodes;
|
||||
public:
|
||||
static boost::mutex locker;
|
||||
static std::mutex locker;
|
||||
static uint32_t version;
|
||||
|
||||
AISharedStorage(int3 sizes, int numChains);
|
||||
|
||||
@@ -216,7 +216,7 @@ ExchangeResult HeroExchangeMap::tryExchangeNoLock(const ChainActor * other)
|
||||
ExchangeResult result;
|
||||
|
||||
{
|
||||
boost::shared_lock lock(sync, boost::try_to_lock);
|
||||
std::shared_lock lock(sync, std::try_to_lock);
|
||||
|
||||
if(!lock.owns_lock())
|
||||
{
|
||||
@@ -236,7 +236,7 @@ ExchangeResult HeroExchangeMap::tryExchangeNoLock(const ChainActor * other)
|
||||
}
|
||||
|
||||
{
|
||||
boost::unique_lock uniqueLock(sync, boost::try_to_lock);
|
||||
std::unique_lock uniqueLock(sync, std::try_to_lock);
|
||||
|
||||
if(!uniqueLock.owns_lock())
|
||||
{
|
||||
|
||||
@@ -802,7 +802,7 @@ void VCAI::makeTurn()
|
||||
auto day = cb->getDate(Date::DAY);
|
||||
logAi->info("Player %d (%s) starting turn, day %d", playerID, playerID.toString(), day);
|
||||
|
||||
boost::shared_lock gsLock(CGameState::mutex);
|
||||
std::shared_lock gsLock(CGameState::mutex);
|
||||
setThreadName("VCAI::makeTurn");
|
||||
|
||||
switch(cb->getDate(Date::DAY_OF_WEEK))
|
||||
@@ -2491,7 +2491,7 @@ void VCAI::recruitHero(const CGTownInstance * t, bool throwing)
|
||||
void VCAI::finish()
|
||||
{
|
||||
//we want to lock to avoid multiple threads from calling makingTurn->join() at same time
|
||||
boost::lock_guard<boost::mutex> multipleCleanupGuard(turnInterruptionMutex);
|
||||
boost::lock_guard<std::mutex> multipleCleanupGuard(turnInterruptionMutex);
|
||||
if(makingTurn)
|
||||
{
|
||||
makingTurn->interrupt();
|
||||
@@ -2506,7 +2506,7 @@ void VCAI::requestActionASAP(std::function<void()> whatToDo)
|
||||
{
|
||||
setThreadName("VCAI::requestActionASAP::whatToDo");
|
||||
SET_GLOBAL_STATE(this);
|
||||
boost::shared_lock gsLock(CGameState::mutex);
|
||||
std::shared_lock gsLock(CGameState::mutex);
|
||||
whatToDo();
|
||||
});
|
||||
|
||||
@@ -2622,7 +2622,7 @@ AIStatus::~AIStatus()
|
||||
|
||||
void AIStatus::setBattle(BattleState BS)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
LOG_TRACE_PARAMS(logAi, "battle state=%d", (int)BS);
|
||||
battle = BS;
|
||||
cv.notify_all();
|
||||
@@ -2630,7 +2630,7 @@ void AIStatus::setBattle(BattleState BS)
|
||||
|
||||
BattleState AIStatus::getBattle()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
return battle;
|
||||
}
|
||||
|
||||
@@ -2643,7 +2643,7 @@ void AIStatus::addQuery(QueryID ID, std::string description)
|
||||
}
|
||||
|
||||
assert(ID.getNum() >= 0);
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
|
||||
assert(!vstd::contains(remainingQueries, ID));
|
||||
|
||||
@@ -2655,7 +2655,7 @@ void AIStatus::addQuery(QueryID ID, std::string description)
|
||||
|
||||
void AIStatus::removeQuery(QueryID ID)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
assert(vstd::contains(remainingQueries, ID));
|
||||
|
||||
std::string description = remainingQueries[ID];
|
||||
@@ -2667,40 +2667,40 @@ void AIStatus::removeQuery(QueryID ID)
|
||||
|
||||
int AIStatus::getQueriesCount()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
return static_cast<int>(remainingQueries.size());
|
||||
}
|
||||
|
||||
void AIStatus::startedTurn()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
havingTurn = true;
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
void AIStatus::madeTurn()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
havingTurn = false;
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
void AIStatus::waitTillFree()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
while(battle != NO_BATTLE || !remainingQueries.empty() || !objectsBeingVisited.empty() || ongoingHeroMovement)
|
||||
cv.wait_for(lock, boost::chrono::milliseconds(100));
|
||||
cv.wait_for(lock, std::chrono::milliseconds(100));
|
||||
}
|
||||
|
||||
bool AIStatus::haveTurn()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
return havingTurn;
|
||||
}
|
||||
|
||||
void AIStatus::attemptedAnsweringQuery(QueryID queryID, int answerRequestID)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
assert(vstd::contains(remainingQueries, queryID));
|
||||
std::string description = remainingQueries[queryID];
|
||||
logAi->debug("Attempted answering query %d - %s. Request id=%d. Waiting for results...", queryID, description, answerRequestID);
|
||||
@@ -2712,7 +2712,7 @@ void AIStatus::receivedAnswerConfirmation(int answerRequestID, int result)
|
||||
QueryID query;
|
||||
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
|
||||
assert(vstd::contains(requestToQueryID, answerRequestID));
|
||||
query = requestToQueryID[answerRequestID];
|
||||
@@ -2733,7 +2733,7 @@ void AIStatus::receivedAnswerConfirmation(int answerRequestID, int result)
|
||||
|
||||
void AIStatus::heroVisit(const CGObjectInstance * obj, bool started)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
if(started)
|
||||
{
|
||||
objectsBeingVisited.push_back(obj);
|
||||
@@ -2751,14 +2751,14 @@ void AIStatus::heroVisit(const CGObjectInstance * obj, bool started)
|
||||
|
||||
void AIStatus::setMove(bool ongoing)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
ongoingHeroMovement = ongoing;
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
void AIStatus::setChannelProbing(bool ongoing)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
std::unique_lock<std::mutex> lock(mx);
|
||||
ongoingChannelProbing = ongoing;
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ class AIhelper;
|
||||
|
||||
class AIStatus
|
||||
{
|
||||
boost::mutex mx;
|
||||
boost::condition_variable cv;
|
||||
std::mutex mx;
|
||||
std::condition_variable cv;
|
||||
|
||||
BattleState battle;
|
||||
std::map<QueryID, std::string> remainingQueries;
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
|
||||
std::unique_ptr<boost::thread> makingTurn;
|
||||
private:
|
||||
boost::mutex turnInterruptionMutex;
|
||||
std::mutex turnInterruptionMutex;
|
||||
public:
|
||||
ObjectInstanceID selectedObject;
|
||||
|
||||
|
||||
1
Global.h
1
Global.h
@@ -120,6 +120,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <codecvt>
|
||||
#include <condition_variable>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
|
||||
@@ -60,10 +60,10 @@ bool ArtifactsUIController::askToAssemble(const CGHeroInstance * hero, const Art
|
||||
{
|
||||
auto askThread = new boost::thread([this, hero, art, slot, assemblyPossibilities, checkIgnored]() -> void
|
||||
{
|
||||
boost::mutex::scoped_lock askLock(askAssembleArtifactMutex);
|
||||
std::scoped_lock askLock(askAssembleArtifactMutex);
|
||||
for(const auto combinedArt : assemblyPossibilities)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
if(checkIgnored)
|
||||
{
|
||||
if(vstd::contains(ignoredArtifacts, combinedArt->getId()))
|
||||
|
||||
@@ -24,7 +24,7 @@ class ArtifactsUIController
|
||||
size_t numOfArtsAskAssembleSession;
|
||||
std::set<ArtifactID> ignoredArtifacts;
|
||||
|
||||
boost::mutex askAssembleArtifactMutex;
|
||||
std::mutex askAssembleArtifactMutex;
|
||||
|
||||
public:
|
||||
ArtifactsUIController();
|
||||
|
||||
@@ -1510,7 +1510,7 @@ void CPlayerInterface::playerBlocked(int reason, bool start)
|
||||
void CPlayerInterface::update()
|
||||
{
|
||||
// Make sure that gamestate won't change when GUI objects may obtain its parts on event processing or drawing request
|
||||
boost::shared_lock gsLock(CGameState::mutex);
|
||||
std::shared_lock gsLock(CGameState::mutex);
|
||||
|
||||
// While mutexes were locked away we may be have stopped being the active interface
|
||||
if (GAME->interface() != this)
|
||||
|
||||
@@ -215,7 +215,7 @@ void CServerHandler::connectToServer(const std::string & addr, const ui16 port)
|
||||
void CServerHandler::onConnectionFailed(const std::string & errorMessage)
|
||||
{
|
||||
assert(getState() == EClientState::CONNECTING);
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
if (isServerLocal())
|
||||
{
|
||||
@@ -233,7 +233,7 @@ void CServerHandler::onConnectionFailed(const std::string & errorMessage)
|
||||
|
||||
void CServerHandler::onTimer()
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
if(getState() == EClientState::CONNECTION_CANCELLED)
|
||||
{
|
||||
@@ -253,7 +253,7 @@ void CServerHandler::onConnectionEstablished(const NetworkConnectionPtr & netCon
|
||||
{
|
||||
assert(getState() == EClientState::CONNECTING);
|
||||
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
networkConnection = netConnection;
|
||||
|
||||
@@ -854,7 +854,7 @@ public:
|
||||
|
||||
void CServerHandler::onPacketReceived(const std::shared_ptr<INetworkConnection> &, const std::vector<std::byte> & message)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
if(getState() == EClientState::DISCONNECTING)
|
||||
return;
|
||||
@@ -866,7 +866,7 @@ void CServerHandler::onPacketReceived(const std::shared_ptr<INetworkConnection>
|
||||
|
||||
void CServerHandler::onDisconnected(const std::shared_ptr<INetworkConnection> & connection, const std::string & errorMessage)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
if (connection != networkConnection)
|
||||
{
|
||||
|
||||
@@ -353,7 +353,7 @@ void CClient::handlePack(CPackForClient & pack)
|
||||
pack.visit(beforeVisitor);
|
||||
logNetwork->trace("\tMade first apply on cl: %s", typeid(pack).name());
|
||||
{
|
||||
boost::unique_lock lock(CGameState::mutex);
|
||||
std::unique_lock lock(CGameState::mutex);
|
||||
gs->apply(pack);
|
||||
}
|
||||
logNetwork->trace("\tApplied on gs: %s", typeid(pack).name());
|
||||
@@ -529,7 +529,7 @@ void CClient::removeGUI() const
|
||||
#ifdef VCMI_ANDROID
|
||||
extern "C" JNIEXPORT jboolean JNICALL Java_eu_vcmi_vcmi_NativeMethods_tryToSaveTheGame(JNIEnv * env, jclass cls)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
logGlobal->info("Received emergency save game request");
|
||||
if(!GAME->interface() || !GAME->interface()->cb)
|
||||
|
||||
@@ -48,10 +48,10 @@ namespace boost { class thread; }
|
||||
template<typename T>
|
||||
class ThreadSafeVector
|
||||
{
|
||||
using TLock = boost::unique_lock<boost::mutex>;
|
||||
using TLock = std::unique_lock<std::mutex>;
|
||||
std::vector<T> items;
|
||||
boost::mutex mx;
|
||||
boost::condition_variable cond;
|
||||
std::mutex mx;
|
||||
std::condition_variable cond;
|
||||
|
||||
public:
|
||||
void clear()
|
||||
|
||||
@@ -75,7 +75,7 @@ void ClientCommandManager::handleGoSoloCommand()
|
||||
{
|
||||
Settings session = settings.write["session"];
|
||||
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
if(!GAME->server().client)
|
||||
{
|
||||
@@ -128,7 +128,7 @@ void ClientCommandManager::handleControlaiCommand(std::istringstream& singleWord
|
||||
singleWordBuffer >> colorName;
|
||||
boost::to_lower(colorName);
|
||||
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
if(!GAME->server().client)
|
||||
{
|
||||
@@ -543,7 +543,7 @@ void ClientCommandManager::printCommandMessage(const std::string &commandMessage
|
||||
|
||||
if(currentCallFromIngameConsole)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
if(GAME->interface() && GAME->interface()->cingconsole)
|
||||
{
|
||||
GAME->interface()->cingconsole->addMessage("", "System", commandMessage);
|
||||
|
||||
@@ -107,7 +107,7 @@ void GameEngine::fakeMouseMove()
|
||||
void GameEngine::renderFrame()
|
||||
{
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
if (nullptr != curInt)
|
||||
curInt->update();
|
||||
|
||||
@@ -55,7 +55,7 @@ private:
|
||||
std::unique_ptr<IVideoPlayer> videoPlayerInstance;
|
||||
|
||||
public:
|
||||
boost::mutex interfaceMutex;
|
||||
std::mutex interfaceMutex;
|
||||
|
||||
/// returns current position of mouse cursor, relative to vcmi window
|
||||
const Point & getCursorPosition() const;
|
||||
|
||||
@@ -149,7 +149,7 @@ void InputHandler::copyToClipBoard(const std::string & text)
|
||||
|
||||
std::vector<SDL_Event> InputHandler::acquireEvents()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(eventsMutex);
|
||||
std::unique_lock<std::mutex> lock(eventsMutex);
|
||||
|
||||
std::vector<SDL_Event> result;
|
||||
std::swap(result, eventsQueue);
|
||||
@@ -171,7 +171,7 @@ bool InputHandler::ignoreEventsUntilInput()
|
||||
{
|
||||
bool inputFound = false;
|
||||
|
||||
boost::unique_lock<boost::mutex> lock(eventsMutex);
|
||||
std::unique_lock<std::mutex> lock(eventsMutex);
|
||||
for(const auto & event : eventsQueue)
|
||||
{
|
||||
switch(event.type)
|
||||
@@ -192,7 +192,7 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
|
||||
{
|
||||
if(ev.type == SDL_QUIT)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
#ifdef VCMI_ANDROID
|
||||
handleQuit(false);
|
||||
#else
|
||||
@@ -205,21 +205,21 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
|
||||
if(ev.key.keysym.sym == SDLK_F4 && (ev.key.keysym.mod & KMOD_ALT))
|
||||
{
|
||||
// FIXME: dead code? Looks like intercepted by OS/SDL and delivered as SDL_Quit instead?
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
handleQuit(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if(ev.key.keysym.scancode == SDL_SCANCODE_AC_BACK && !settings["input"]["handleBackRightMouseButton"].Bool())
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
handleQuit(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(ev.type == SDL_USEREVENT)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
handleUserEvent(ev.user);
|
||||
|
||||
return;
|
||||
@@ -230,7 +230,7 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
#ifndef VCMI_IOS
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
ENGINE->onScreenResize(false);
|
||||
}
|
||||
#endif
|
||||
@@ -238,14 +238,14 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
#ifdef VCMI_ANDROID
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
ENGINE->onScreenResize(true);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
if(settings["general"]["audioMuteFocus"].Bool()) {
|
||||
ENGINE->music().setVolume(settings["general"]["music"].Integer());
|
||||
ENGINE->sound().setVolume(settings["general"]["sound"].Integer());
|
||||
@@ -254,7 +254,7 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
if(settings["general"]["audioMuteFocus"].Bool()) {
|
||||
ENGINE->music().setVolume(0);
|
||||
ENGINE->sound().setVolume(0);
|
||||
@@ -266,7 +266,7 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
|
||||
}
|
||||
else if(ev.type == SDL_SYSWMEVENT)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
if(!settings["session"]["headless"].Bool() && settings["general"]["notifications"].Bool())
|
||||
{
|
||||
NotificationHandler::handleSdlEvent(ev);
|
||||
@@ -291,12 +291,12 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
|
||||
//preprocessing
|
||||
if(ev.type == SDL_MOUSEMOTION)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
ENGINE->cursor().cursorMove(ev.motion.x, ev.motion.y);
|
||||
}
|
||||
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(eventsMutex);
|
||||
std::unique_lock<std::mutex> lock(eventsMutex);
|
||||
|
||||
// In a sequence of motion events, skip all but the last one.
|
||||
// This prevents freezes when every motion event takes longer to handle than interval at which
|
||||
|
||||
@@ -33,7 +33,7 @@ enum class InputMode
|
||||
class InputHandler
|
||||
{
|
||||
std::vector<SDL_Event> eventsQueue;
|
||||
boost::mutex eventsMutex;
|
||||
std::mutex eventsMutex;
|
||||
|
||||
Point cursorPosition;
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ GlobalLobbyClient::~GlobalLobbyClient() = default;
|
||||
|
||||
void GlobalLobbyClient::onPacketReceived(const std::shared_ptr<INetworkConnection> &, const std::vector<std::byte> & message)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
JsonNode json(message.data(), message.size(), "<lobby network packet>");
|
||||
|
||||
@@ -364,7 +364,7 @@ void GlobalLobbyClient::receiveJoinRoomSuccess(const JsonNode & json)
|
||||
|
||||
void GlobalLobbyClient::onConnectionEstablished(const std::shared_ptr<INetworkConnection> & connection)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
networkConnection = connection;
|
||||
|
||||
auto loginWindowPtr = loginWindow.lock();
|
||||
@@ -402,7 +402,7 @@ void GlobalLobbyClient::sendClientLogin()
|
||||
|
||||
void GlobalLobbyClient::onConnectionFailed(const std::string & errorMessage)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
auto loginWindowPtr = loginWindow.lock();
|
||||
|
||||
@@ -415,7 +415,7 @@ void GlobalLobbyClient::onConnectionFailed(const std::string & errorMessage)
|
||||
|
||||
void GlobalLobbyClient::onDisconnected(const std::shared_ptr<INetworkConnection> & connection, const std::string & errorMessage)
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||
|
||||
assert(connection == networkConnection);
|
||||
networkConnection.reset();
|
||||
|
||||
@@ -88,7 +88,7 @@ CMusicHandler::~CMusicHandler()
|
||||
{
|
||||
if(isInitialized())
|
||||
{
|
||||
boost::mutex::scoped_lock guard(mutex);
|
||||
std::scoped_lock guard(mutex);
|
||||
|
||||
Mix_HookMusicFinished(nullptr);
|
||||
current->stop();
|
||||
@@ -100,7 +100,7 @@ CMusicHandler::~CMusicHandler()
|
||||
|
||||
void CMusicHandler::playMusic(const AudioPath & musicURI, bool loop, bool fromStart)
|
||||
{
|
||||
boost::mutex::scoped_lock guard(mutex);
|
||||
std::scoped_lock guard(mutex);
|
||||
|
||||
if(current && current->isPlaying() && current->isTrack(musicURI))
|
||||
return;
|
||||
@@ -115,7 +115,7 @@ void CMusicHandler::playMusicFromSet(const std::string & musicSet, const std::st
|
||||
|
||||
void CMusicHandler::playMusicFromSet(const std::string & whichSet, bool loop, bool fromStart)
|
||||
{
|
||||
boost::mutex::scoped_lock guard(mutex);
|
||||
std::scoped_lock guard(mutex);
|
||||
|
||||
auto selectedSet = musicsSet.find(whichSet);
|
||||
if(selectedSet == musicsSet.end())
|
||||
@@ -155,7 +155,7 @@ void CMusicHandler::stopMusic(int fade_ms)
|
||||
if(!isInitialized())
|
||||
return;
|
||||
|
||||
boost::mutex::scoped_lock guard(mutex);
|
||||
std::scoped_lock guard(mutex);
|
||||
|
||||
if(current != nullptr)
|
||||
current->stop(fade_ms);
|
||||
@@ -188,7 +188,7 @@ void CMusicHandler::musicFinishedCallback()
|
||||
ENGINE->dispatchMainThread(
|
||||
[this]()
|
||||
{
|
||||
boost::unique_lock lockGuard(mutex);
|
||||
std::unique_lock lockGuard(mutex);
|
||||
if(current != nullptr)
|
||||
{
|
||||
// if music is looped, play it again
|
||||
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
std::unique_ptr<MusicEntry> current;
|
||||
std::unique_ptr<MusicEntry> next;
|
||||
|
||||
boost::mutex mutex;
|
||||
std::mutex mutex;
|
||||
int volume = 0; // from 0 (mute) to 100
|
||||
|
||||
void queueNext(CMusicHandler * owner, const std::string & setName, const AudioPath & musicURI, bool looped, bool fromStart);
|
||||
|
||||
@@ -283,7 +283,7 @@ void CSoundHandler::setChannelVolume(int channel, ui32 percent)
|
||||
|
||||
void CSoundHandler::setCallback(int channel, std::function<void()> function)
|
||||
{
|
||||
boost::mutex::scoped_lock lockGuard(mutexCallbacks);
|
||||
std::scoped_lock lockGuard(mutexCallbacks);
|
||||
|
||||
auto iter = callbacks.find(channel);
|
||||
|
||||
@@ -296,14 +296,14 @@ void CSoundHandler::setCallback(int channel, std::function<void()> function)
|
||||
|
||||
void CSoundHandler::resetCallback(int channel)
|
||||
{
|
||||
boost::mutex::scoped_lock lockGuard(mutexCallbacks);
|
||||
std::scoped_lock lockGuard(mutexCallbacks);
|
||||
|
||||
callbacks.erase(channel);
|
||||
}
|
||||
|
||||
void CSoundHandler::soundFinishedCallback(int channel)
|
||||
{
|
||||
boost::mutex::scoped_lock lockGuard(mutexCallbacks);
|
||||
std::scoped_lock lockGuard(mutexCallbacks);
|
||||
|
||||
if(callbacks.count(channel) == 0)
|
||||
return;
|
||||
@@ -327,14 +327,14 @@ void CSoundHandler::soundFinishedCallback(int channel)
|
||||
|
||||
void CSoundHandler::initCallback(int channel)
|
||||
{
|
||||
boost::mutex::scoped_lock lockGuard(mutexCallbacks);
|
||||
std::scoped_lock lockGuard(mutexCallbacks);
|
||||
assert(callbacks.count(channel) == 0);
|
||||
callbacks[channel] = {};
|
||||
}
|
||||
|
||||
void CSoundHandler::initCallback(int channel, const std::function<void()> & function)
|
||||
{
|
||||
boost::mutex::scoped_lock lockGuard(mutexCallbacks);
|
||||
std::scoped_lock lockGuard(mutexCallbacks);
|
||||
assert(callbacks.count(channel) == 0);
|
||||
callbacks[channel].push_back(function);
|
||||
}
|
||||
@@ -346,7 +346,7 @@ int CSoundHandler::ambientGetRange() const
|
||||
|
||||
void CSoundHandler::ambientUpdateChannels(std::map<AudioPath, int> soundsArg)
|
||||
{
|
||||
boost::mutex::scoped_lock guard(mutex);
|
||||
std::scoped_lock guard(mutex);
|
||||
|
||||
std::vector<AudioPath> stoppedSounds;
|
||||
for(const auto & pair : ambientChannels)
|
||||
@@ -391,7 +391,7 @@ void CSoundHandler::ambientUpdateChannels(std::map<AudioPath, int> soundsArg)
|
||||
|
||||
void CSoundHandler::ambientStopAllChannels()
|
||||
{
|
||||
boost::mutex::scoped_lock guard(mutex);
|
||||
std::scoped_lock guard(mutex);
|
||||
|
||||
for(const auto & ch : ambientChannels)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
|
||||
/// Protects access to callbacks member to avoid data races:
|
||||
/// SDL calls sound finished callbacks from audio thread
|
||||
boost::mutex mutexCallbacks;
|
||||
std::mutex mutexCallbacks;
|
||||
|
||||
int ambientDistToVolume(int distance) const;
|
||||
void ambientStopSound(const AudioPath & soundId);
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
|
||||
const JsonNode ambientConfig;
|
||||
|
||||
boost::mutex mutex;
|
||||
std::mutex mutex;
|
||||
std::map<AudioPath, int> ambientChannels;
|
||||
std::map<int, int> channelVolumes;
|
||||
int volume = 0;
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
|
||||
std::unique_ptr<EventSubscription> subscribeBefore(BusTag tag, PreHandler && handler)
|
||||
{
|
||||
boost::unique_lock<boost::shared_mutex> lock(mutex);
|
||||
std::unique_lock<boost::shared_mutex> lock(mutex);
|
||||
|
||||
auto storage = std::make_shared<PreHandlerStorage>(std::move(handler));
|
||||
preHandlers[tag].push_back(storage);
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
|
||||
std::unique_ptr<EventSubscription> subscribeAfter(BusTag tag, PostHandler && handler)
|
||||
{
|
||||
boost::unique_lock<boost::shared_mutex> lock(mutex);
|
||||
std::unique_lock<boost::shared_mutex> lock(mutex);
|
||||
|
||||
auto storage = std::make_shared<PostHandlerStorage>(std::move(handler));
|
||||
postHandlers[tag].push_back(storage);
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
void executeEvent(const EventBus * bus, E & event, const ExecHandler & execHandler)
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(mutex);
|
||||
std::shared_lock<boost::shared_mutex> lock(mutex);
|
||||
{
|
||||
auto it = preHandlers.find(bus);
|
||||
|
||||
@@ -149,7 +149,7 @@ private:
|
||||
template <typename T>
|
||||
void unsubscribe(BusTag tag, T what, std::map<BusTag, std::vector<T>> & from)
|
||||
{
|
||||
boost::unique_lock<boost::shared_mutex> lock(mutex);
|
||||
std::unique_lock<boost::shared_mutex> lock(mutex);
|
||||
|
||||
auto it = from.find(tag);
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ const IMarket * CGameInfoCallback::getMarket(ObjectInstanceID objid) const
|
||||
|
||||
void CGameInfoCallback::fillUpgradeInfo(const CArmedInstance *obj, SlotID stackPos, UpgradeInfo & out) const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
ERROR_RET_IF(!canGetFullInfo(obj), "Cannot get info about not owned object!");
|
||||
ERROR_RET_IF(!obj->hasStackAtSlot(stackPos), "There is no such stack!");
|
||||
gs->fillUpgradeInfo(obj, stackPos, out);
|
||||
@@ -194,7 +194,7 @@ void CGameInfoCallback::fillUpgradeInfo(const CArmedInstance *obj, SlotID stackP
|
||||
|
||||
const StartInfo * CGameInfoCallback::getStartInfo(bool beforeRandomization) const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
if(beforeRandomization)
|
||||
return gs->initialOpts;
|
||||
else
|
||||
@@ -203,7 +203,7 @@ const StartInfo * CGameInfoCallback::getStartInfo(bool beforeRandomization) cons
|
||||
|
||||
int32_t CGameInfoCallback::getSpellCost(const spells::Spell * sp, const CGHeroInstance * caster) const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
ERROR_RET_VAL_IF(!canGetFullInfo(caster), "Cannot get info about caster!", -1);
|
||||
//if there is a battle
|
||||
auto casterBattle = gs->getBattle(caster->getOwner());
|
||||
@@ -217,7 +217,7 @@ int32_t CGameInfoCallback::getSpellCost(const spells::Spell * sp, const CGHeroIn
|
||||
|
||||
int64_t CGameInfoCallback::estimateSpellDamage(const CSpell * sp, const CGHeroInstance * hero) const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
|
||||
ERROR_RET_VAL_IF(hero && !canGetFullInfo(hero), "Cannot get info about caster!", -1);
|
||||
|
||||
@@ -229,7 +229,7 @@ int64_t CGameInfoCallback::estimateSpellDamage(const CSpell * sp, const CGHeroIn
|
||||
|
||||
void CGameInfoCallback::getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj)
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
ERROR_RET_IF(!obj, "No guild object!");
|
||||
ERROR_RET_IF(obj->ID == Obj::TOWN && !canGetFullInfo(obj), "Cannot get info about town guild object!");
|
||||
//TODO: advmap object -> check if they're visited by our hero
|
||||
@@ -419,13 +419,13 @@ bool CGameInfoCallback::getHeroInfo(const CGObjectInstance * hero, InfoAboutHero
|
||||
|
||||
int CGameInfoCallback::getDate(Date mode) const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
return gs->getDate(mode);
|
||||
}
|
||||
|
||||
bool CGameInfoCallback::isVisible(int3 pos, const std::optional<PlayerColor> & Player) const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
return gs->isVisible(pos, Player);
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ bool CGameInfoCallback::isVisible(const CGObjectInstance *obj) const
|
||||
}
|
||||
// const CCreatureSet* CInfoCallback::getGarrison(const CGObjectInstance *obj) const
|
||||
// {
|
||||
// //boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
// //std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
// if()
|
||||
// const CArmedInstance *armi = dynamic_cast<const CArmedInstance*>(obj);
|
||||
// if(!armi)
|
||||
@@ -754,14 +754,14 @@ CGameInfoCallback::CGameInfoCallback(CGameState * GS):
|
||||
|
||||
int CPlayerSpecificInfoCallback::howManyTowns() const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
ERROR_RET_VAL_IF(!getPlayerID(), "Applicable only for player callbacks", -1);
|
||||
return CGameInfoCallback::howManyTowns(*getPlayerID());
|
||||
}
|
||||
|
||||
std::vector < const CGTownInstance *> CPlayerSpecificInfoCallback::getTownsInfo(bool onlyOur) const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
auto ret = std::vector < const CGTownInstance *>();
|
||||
for(const auto & i : gs->players)
|
||||
{
|
||||
@@ -777,7 +777,7 @@ std::vector < const CGTownInstance *> CPlayerSpecificInfoCallback::getTownsInfo(
|
||||
}
|
||||
std::vector < const CGHeroInstance *> CPlayerSpecificInfoCallback::getHeroesInfo(bool onlyOur) const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
std::vector < const CGHeroInstance *> ret;
|
||||
for(auto hero : gs->map->heroesOnMap)
|
||||
{
|
||||
@@ -840,7 +840,7 @@ std::vector <QuestInfo> CPlayerSpecificInfoCallback::getMyQuests() const
|
||||
|
||||
int CPlayerSpecificInfoCallback::howManyHeroes(bool includeGarrisoned) const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
ERROR_RET_VAL_IF(!getPlayerID(), "Applicable only for player callbacks", -1);
|
||||
return getHeroCount(*getPlayerID(), includeGarrisoned);
|
||||
}
|
||||
@@ -872,14 +872,14 @@ const CGTownInstance* CPlayerSpecificInfoCallback::getTownBySerial(int serialId)
|
||||
|
||||
int CPlayerSpecificInfoCallback::getResourceAmount(GameResID type) const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
ERROR_RET_VAL_IF(!getPlayerID(), "Applicable only for player callbacks", -1);
|
||||
return getResource(*getPlayerID(), type);
|
||||
}
|
||||
|
||||
TResources CPlayerSpecificInfoCallback::getResourceAmount() const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
//std::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
ERROR_RET_VAL_IF(!getPlayerID(), "Applicable only for player callbacks", TResources());
|
||||
return gs->players[*getPlayerID()].resources;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ void CThreadHelper::processTasks()
|
||||
{
|
||||
int pom;
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(rtinm);
|
||||
std::unique_lock<std::mutex> lock(rtinm);
|
||||
if((pom = currentTask) >= amount)
|
||||
break;
|
||||
else
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
CThreadHelper(std::vector<std::function<void()> > *Tasks, int Threads);
|
||||
void run();
|
||||
private:
|
||||
boost::mutex rtinm;
|
||||
std::mutex rtinm;
|
||||
int currentTask;
|
||||
int amount;
|
||||
int threads;
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
//thread group deletes threads, do not free manually
|
||||
}
|
||||
private:
|
||||
boost::mutex rtinm;
|
||||
std::mutex rtinm;
|
||||
size_t currentTask;
|
||||
size_t amount;
|
||||
size_t threads;
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
{
|
||||
size_t pom;
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(rtinm);
|
||||
std::unique_lock<std::mutex> lock(rtinm);
|
||||
if((pom = currentTask) >= amount)
|
||||
break;
|
||||
else
|
||||
|
||||
@@ -92,13 +92,13 @@ void Progress::step(int count)
|
||||
|
||||
void ProgressAccumulator::include(const Progress & p)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> guard(_mx);
|
||||
std::unique_lock<std::mutex> guard(_mx);
|
||||
_progress.emplace_back(p);
|
||||
}
|
||||
|
||||
void ProgressAccumulator::exclude(const Progress & p)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> guard(_mx);
|
||||
std::unique_lock<std::mutex> guard(_mx);
|
||||
for(auto i = _progress.begin(); i != _progress.end(); ++i)
|
||||
{
|
||||
if(&i->get() == &p)
|
||||
@@ -113,7 +113,7 @@ void ProgressAccumulator::exclude(const Progress & p)
|
||||
|
||||
bool ProgressAccumulator::finished() const
|
||||
{
|
||||
boost::unique_lock<boost::mutex> guard(_mx);
|
||||
std::unique_lock<std::mutex> guard(_mx);
|
||||
for(auto i : _progress)
|
||||
if(!i.get().finished())
|
||||
return false;
|
||||
@@ -122,7 +122,7 @@ bool ProgressAccumulator::finished() const
|
||||
|
||||
Type ProgressAccumulator::get() const
|
||||
{
|
||||
boost::unique_lock<boost::mutex> guard(_mx);
|
||||
std::unique_lock<std::mutex> guard(_mx);
|
||||
auto sum = _accumulated;
|
||||
auto totalSteps = _steps;
|
||||
for(auto p : _progress)
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
Type get() const;
|
||||
|
||||
private:
|
||||
mutable boost::mutex _mx;
|
||||
mutable std::mutex _mx;
|
||||
long long _accumulated = 0;
|
||||
long long _steps = 0;
|
||||
std::vector<std::reference_wrapper<const Progress>> _progress;
|
||||
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
vstd::RNG & getRand();
|
||||
public:
|
||||
mutable std::recursive_mutex areaMutex;
|
||||
using Lock = boost::unique_lock<std::recursive_mutex>;
|
||||
using Lock = std::unique_lock<std::recursive_mutex>;
|
||||
|
||||
protected:
|
||||
CMapGenerator & generator;
|
||||
|
||||
@@ -37,8 +37,8 @@ std::pair<Zone::Lock, Zone::Lock> ConnectionsPlacer::lockZones(std::shared_ptr<Z
|
||||
|
||||
while (true)
|
||||
{
|
||||
auto lock1 = Zone::Lock(zone.areaMutex, boost::try_to_lock);
|
||||
auto lock2 = Zone::Lock(otherZone->areaMutex, boost::try_to_lock);
|
||||
auto lock1 = Zone::Lock(zone.areaMutex, std::try_to_lock);
|
||||
auto lock2 = Zone::Lock(otherZone->areaMutex, std::try_to_lock);
|
||||
|
||||
if (lock1.owns_lock() && lock2.owns_lock())
|
||||
{
|
||||
@@ -71,8 +71,8 @@ void ConnectionsPlacer::process()
|
||||
|
||||
while (cp)
|
||||
{
|
||||
RecursiveLock lock1(externalAccessMutex, boost::try_to_lock);
|
||||
RecursiveLock lock2(cp->externalAccessMutex, boost::try_to_lock);
|
||||
RecursiveLock lock1(externalAccessMutex, std::try_to_lock);
|
||||
RecursiveLock lock2(cp->externalAccessMutex, std::try_to_lock);
|
||||
if (lock1.owns_lock() && lock2.owns_lock())
|
||||
{
|
||||
if (!vstd::contains(dCompleted, c))
|
||||
|
||||
@@ -35,7 +35,7 @@ const std::string & Modificator::getName() const
|
||||
|
||||
bool Modificator::isReady()
|
||||
{
|
||||
Lock lock(mx, boost::try_to_lock);
|
||||
Lock lock(mx, std::try_to_lock);
|
||||
if (!lock.owns_lock())
|
||||
{
|
||||
return false;
|
||||
@@ -63,7 +63,7 @@ bool Modificator::isReady()
|
||||
|
||||
bool Modificator::isFinished()
|
||||
{
|
||||
Lock lock(mx, boost::try_to_lock);
|
||||
Lock lock(mx, std::try_to_lock);
|
||||
if (!lock.owns_lock())
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -63,8 +63,8 @@ protected:
|
||||
bool finished = false;
|
||||
|
||||
mutable std::recursive_mutex externalAccessMutex; //Used to communicate between Modificators
|
||||
using RecursiveLock = boost::unique_lock<std::recursive_mutex>;
|
||||
using Lock = boost::unique_lock<boost::shared_mutex>;
|
||||
using RecursiveLock = std::unique_lock<std::recursive_mutex>;
|
||||
using Lock = std::unique_lock<boost::shared_mutex>;
|
||||
|
||||
private:
|
||||
virtual void process() = 0;
|
||||
|
||||
@@ -121,7 +121,7 @@ void ObjectManager::updateDistances(const int3 & pos)
|
||||
void ObjectManager::updateDistances(std::function<ui32(const int3 & tile)> distanceFunction)
|
||||
{
|
||||
// Workaround to avoid deadlock when accessed from other zone
|
||||
RecursiveLock lock(zone.areaMutex, boost::try_to_lock);
|
||||
RecursiveLock lock(zone.areaMutex, std::try_to_lock);
|
||||
if (!lock.owns_lock())
|
||||
{
|
||||
// Unsolvable problem of mutual access
|
||||
|
||||
@@ -19,8 +19,8 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
template <typename T>
|
||||
class DLL_LINKAGE BlockingQueue : protected std::queue<T>
|
||||
{
|
||||
using WriteLock = boost::unique_lock<boost::shared_mutex>;
|
||||
using Readlock = boost::shared_lock<boost::shared_mutex>;
|
||||
using WriteLock = std::unique_lock<boost::shared_mutex>;
|
||||
using Readlock = std::shared_lock<boost::shared_mutex>;
|
||||
|
||||
public:
|
||||
BlockingQueue() = default;
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
private:
|
||||
mutable boost::shared_mutex mx;
|
||||
using Lock = boost::unique_lock<boost::shared_mutex>;
|
||||
using Lock = std::unique_lock<boost::shared_mutex>;
|
||||
|
||||
RmgMap & map;
|
||||
};
|
||||
|
||||
@@ -24,9 +24,9 @@ typedef std::optional<TRMGfunction> TRMGJob;
|
||||
class DLL_LINKAGE ThreadPool
|
||||
{
|
||||
private:
|
||||
using Lock = boost::unique_lock<boost::shared_mutex>;
|
||||
using Lock = std::unique_lock<boost::shared_mutex>;
|
||||
mutable boost::shared_mutex mx;
|
||||
mutable boost::condition_variable_any cv;
|
||||
mutable std::condition_variable_any cv;
|
||||
mutable boost::once_flag once;
|
||||
|
||||
bool isInitialized = false;
|
||||
|
||||
@@ -70,7 +70,7 @@ CConnection::~CConnection() = default;
|
||||
|
||||
void CConnection::sendPack(const CPack & pack)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(writeMutex);
|
||||
std::scoped_lock lock(writeMutex);
|
||||
|
||||
auto connectionPtr = networkConnection.lock();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class DLL_LINKAGE CConnection : boost::noncopyable
|
||||
std::unique_ptr<BinaryDeserializer> deserializer;
|
||||
std::unique_ptr<BinarySerializer> serializer;
|
||||
|
||||
boost::mutex writeMutex;
|
||||
std::mutex writeMutex;
|
||||
|
||||
void disableStackSendingByID();
|
||||
void enableStackSendingByID();
|
||||
|
||||
@@ -65,7 +65,7 @@ const char * TypeRegistry::getKeyForType(const std::type_info & type)
|
||||
|
||||
std::type_index typeIndex(type);
|
||||
|
||||
boost::unique_lock<boost::mutex> lock(mutex);
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
|
||||
auto iter = keys.find(typeIndex);
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
private:
|
||||
size_t nextIndex;
|
||||
|
||||
boost::mutex mutex;
|
||||
std::mutex mutex;
|
||||
|
||||
std::map<std::type_index, std::string> keys;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user