1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

* new file lib/UnlockGuard.h — unlock_guard is for unlocking a mutex for the scope time (RAII)

* all lock/unlock and unlock/lock pairs are done by RAII guards now
* fixed two possible crashes at the end of battle when last stack was killed by spell. That should fix #749 and #752.
* fixed a very nasty race condition, eliminating possible deadlock at the start of battle when human hero has tactics
* fixed #422
This commit is contained in:
Michał W. Urbańczyk
2012-02-19 21:03:43 +00:00
parent b35636d5e9
commit e4dc00abac
18 changed files with 239 additions and 131 deletions

View File

@@ -33,6 +33,7 @@
#include "../lib/GameConstants.h"
#include <boost/asio.hpp>
#include "../lib/UnlockGuard.h"
std::string NAME_AFFIX = "server";
std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; //application name
@@ -97,9 +98,8 @@ void CPregameServer::handleConnection(CConnection *cpc)
if(startingGame)
{
//wait for sending thread to announce start
mx.unlock();
auto unlock = vstd::makeUnlockGuard(mx);
while(state == RUNNING) boost::this_thread::sleep(boost::posix_time::milliseconds(50));
mx.lock();
}
}
}