1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-16 02:47:36 +02:00

Relaxed some locks in VCAI.

This commit is contained in:
DjWarmonger 2015-08-31 09:18:24 +02:00
parent 1c14dbf7b2
commit afe65d1264

View File

@ -701,12 +701,12 @@ void makePossibleUpgrades(const CArmedInstance *obj)
void VCAI::makeTurn()
{
logGlobal->infoStream() << boost::format("Player %d starting turn") % static_cast<int>(playerID.getNum());
MAKING_TURN;
boost::shared_lock<boost::shared_mutex> gsLock(cb->getGsMutex());
setThreadName("VCAI::makeTurn");
logGlobal->infoStream() << boost::format("Player %d starting turn") % static_cast<int>(playerID.getNum());
switch(cb->getDate(Date::DAY_OF_WEEK))
{
case 1:
@ -2773,18 +2773,20 @@ BattleState AIStatus::getBattle()
}
void AIStatus::addQuery(QueryID ID, std::string description)
{
boost::unique_lock<boost::mutex> lock(mx);
{
if(ID == QueryID(-1))
{
logAi->debugStream() << boost::format("The \"query\" has an id %d, it'll be ignored as non-query. Description: %s") % ID % description;
return;
}
assert(!vstd::contains(remainingQueries, ID));
assert(ID.getNum() >= 0);
boost::unique_lock<boost::mutex> lock(mx);
assert(!vstd::contains(remainingQueries, ID));
remainingQueries[ID] = description;
cv.notify_all();
logAi->debugStream() << boost::format("Adding query %d - %s. Total queries count: %d") % ID % description % remainingQueries.size();
}
@ -2796,6 +2798,7 @@ void AIStatus::removeQuery(QueryID ID)
std::string description = remainingQueries[ID];
remainingQueries.erase(ID);
cv.notify_all();
logAi->debugStream() << boost::format("Removing query %d - %s. Total queries count: %d") % ID % description % remainingQueries.size();
}