Merge pull request #217 from edisenwangK/fixbug_tc_timer_memory_leak

修复在重复定时处理函数中,删除定时任务时_tmeEvent造成得内存泄露
This commit is contained in:
ruanshudong 2022-02-11 14:03:14 +08:00 committed by GitHub
commit c8f541fcce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -195,6 +195,11 @@ protected:
shared_ptr<Func> p = wPtr.lock();
if(p)
{
{
std::unique_lock <std::mutex> lock(_mutex);
_tmpEvent.erase(p->_uniqueId);
}
if (this->exist(p->_uniqueId, true))
{
if (p->_cron.isset)
@ -208,8 +213,6 @@ protected:
p->_fireMillseconds = TC_TimeProvider::getInstance()->getNowMs() + repeatTime;
this->post(p);
}
_tmpEvent.erase(p->_uniqueId);
}
}
};