mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Remove undefined behavior in requestActionASAP
This commit is contained in:
parent
0fab319c73
commit
0661aa0e6e
@ -2705,24 +2705,13 @@ void VCAI::finish()
|
||||
|
||||
void VCAI::requestActionASAP(std::function<void()> whatToDo)
|
||||
{
|
||||
boost::mutex mutex;
|
||||
mutex.lock();
|
||||
|
||||
boost::thread newThread([&mutex,this,whatToDo]()
|
||||
boost::thread newThread([this,whatToDo]()
|
||||
{
|
||||
setThreadName("VCAI::requestActionASAP::whatToDo");
|
||||
SET_GLOBAL_STATE(this);
|
||||
boost::shared_lock<boost::shared_mutex> gsLock(cb->getGsMutex());
|
||||
// unlock mutex and allow parent function to exit
|
||||
mutex.unlock();
|
||||
whatToDo();
|
||||
});
|
||||
|
||||
// wait for mutex to unlock and for thread to initialize properly
|
||||
mutex.lock();
|
||||
|
||||
// unlock mutex - boost dislikes destruction of locked mutexes
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void VCAI::lostHero(HeroPtr h)
|
||||
|
Loading…
Reference in New Issue
Block a user