确保能同步取消定时器

This commit is contained in:
xiongziliang 2020-04-26 19:36:17 +08:00
parent 341bb5d84a
commit 7272f01ea9

View File

@ -70,10 +70,10 @@ public:
void start(int ms ,EventPoller &poller){ void start(int ms ,EventPoller &poller){
weak_ptr<TimerForC> weak_self = shared_from_this(); weak_ptr<TimerForC> weak_self = shared_from_this();
poller.doDelayTask(ms, [weak_self](){ _task = poller.doDelayTask(ms, [weak_self]() {
auto strong_self = weak_self.lock(); auto strong_self = weak_self.lock();
if(!strong_self){ if (!strong_self) {
return (uint64_t)0; return (uint64_t) 0;
} }
return (*strong_self)(); return (*strong_self)();
}); });