Browse Source

Remove undefined behavior in requestActionASAP

Vadim Markovtsev 10 years ago
parent
commit
0661aa0e6e
1 changed files with 1 additions and 12 deletions
  1. 1 12
      AI/VCAI/VCAI.cpp

+ 1 - 12
AI/VCAI/VCAI.cpp

@@ -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)