Try fix data race for people trying to mthread

This commit is contained in:
Rochet2
2018-04-25 21:47:36 +03:00
parent 25b7700b0f
commit 476cdcd2c3

View File

@@ -16,6 +16,7 @@ extern "C"
ElunaEventProcessor::ElunaEventProcessor(Eluna** _E, WorldObject* _obj) : m_time(0), obj(_obj), E(_E) ElunaEventProcessor::ElunaEventProcessor(Eluna** _E, WorldObject* _obj) : m_time(0), obj(_obj), E(_E)
{ {
// can be called from multiple threads
if (obj) if (obj)
{ {
EventMgr::Guard guard((*E)->eventMgr->GetLock()); EventMgr::Guard guard((*E)->eventMgr->GetLock());
@@ -25,7 +26,11 @@ ElunaEventProcessor::ElunaEventProcessor(Eluna** _E, WorldObject* _obj) : m_time
ElunaEventProcessor::~ElunaEventProcessor() ElunaEventProcessor::~ElunaEventProcessor()
{ {
RemoveEvents_internal(); // can be called from multiple threads
{
LOCK_ELUNA;
RemoveEvents_internal();
}
if (obj && Eluna::IsInitialized()) if (obj && Eluna::IsInitialized())
{ {