mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +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:
@@ -25,6 +25,7 @@
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
#include "lib/UnlockGuard.h"
|
||||
|
||||
/*
|
||||
* CCallback.cpp, part of VCMI engine
|
||||
@@ -230,11 +231,11 @@ void CBattleCallback::sendRequest(const CPack* request)
|
||||
|
||||
if(waitTillRealize)
|
||||
{
|
||||
std::unique_ptr<vstd::unlock_shared_guard> unlocker; //optional, if flag set
|
||||
if(unlockGsWhenWaiting)
|
||||
getGsMutex().unlock_shared();
|
||||
unlocker = vstd::make_unique<vstd::unlock_shared_guard>(vstd::makeUnlockSharedGuard(getGsMutex()));
|
||||
|
||||
cl->waitingRequest.waitWhileTrue();
|
||||
if(unlockGsWhenWaiting)
|
||||
getGsMutex().lock_shared();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user