mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-17 00:07:41 +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:
@ -32,18 +32,14 @@ void CThreadHelper::processTasks()
|
||||
int pom;
|
||||
while(true)
|
||||
{
|
||||
rtinm.lock();
|
||||
if((pom=currentTask) >= amount)
|
||||
{
|
||||
rtinm.unlock();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
++currentTask;
|
||||
rtinm.unlock();
|
||||
(*tasks)[pom]();
|
||||
boost::unique_lock<boost::mutex> lock(rtinm);
|
||||
if((pom = currentTask) >= amount)
|
||||
break;
|
||||
else
|
||||
++currentTask;
|
||||
}
|
||||
(*tasks)[pom]();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user