mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Thread interruption fixes
This commit is contained in:
parent
54bbf2abb3
commit
545b07b8b8
@ -2447,6 +2447,8 @@ void VCAI::recruitHero(const CGTownInstance * t, bool throwing)
|
|||||||
|
|
||||||
void VCAI::finish()
|
void VCAI::finish()
|
||||||
{
|
{
|
||||||
|
//we want to lock to avoid multiple threads from calling makingTurn->join() at same time
|
||||||
|
boost::lock_guard<boost::mutex> multipleCleanupGuard(turnInterruptionMutex);
|
||||||
if(makingTurn)
|
if(makingTurn)
|
||||||
{
|
{
|
||||||
makingTurn->interrupt();
|
makingTurn->interrupt();
|
||||||
|
@ -112,6 +112,9 @@ public:
|
|||||||
std::shared_ptr<CCallback> myCb;
|
std::shared_ptr<CCallback> myCb;
|
||||||
|
|
||||||
std::unique_ptr<boost::thread> makingTurn;
|
std::unique_ptr<boost::thread> makingTurn;
|
||||||
|
private:
|
||||||
|
boost::mutex turnInterruptionMutex;
|
||||||
|
public:
|
||||||
ObjectInstanceID selectedObject;
|
ObjectInstanceID selectedObject;
|
||||||
|
|
||||||
AIhelper * ah;
|
AIhelper * ah;
|
||||||
|
2
Global.h
2
Global.h
@ -167,6 +167,8 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
|
|||||||
# define BOOST_THREAD_VERSION 3
|
# define BOOST_THREAD_VERSION 3
|
||||||
#endif
|
#endif
|
||||||
#define BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE 1
|
#define BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE 1
|
||||||
|
//need to link boost thread dynamically to avoid https://stackoverflow.com/questions/35978572/boost-thread-interupt-does-not-work-when-crossing-a-dll-boundary
|
||||||
|
#define BOOST_THREAD_USE_DLL //for example VCAI::finish() may freeze on thread join after interrupt when linking this statically
|
||||||
#define BOOST_BIND_NO_PLACEHOLDERS
|
#define BOOST_BIND_NO_PLACEHOLDERS
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER == 1900 || _MSC_VER == 1910 || _MSC_VER == 1911)
|
#if defined(_MSC_VER) && (_MSC_VER == 1900 || _MSC_VER == 1910 || _MSC_VER == 1911)
|
||||||
|
Loading…
Reference in New Issue
Block a user