This commit is contained in:
aozhiwei 2023-05-24 22:42:20 +08:00
parent 15ea46ca30
commit e1e32e2800
2 changed files with 7 additions and 2 deletions

View File

@ -135,7 +135,11 @@ void TimerPromise::DoAwait()
[self] (int event, const a8::Args* args) mutable
{
if (event == a8::TIMER_EXEC_EVENT) {
for (auto notifyer : self->notifyers_) {
if (!notifyer.expired()) {
notifyer.lock()->DoResume();
}
}
}
});
}

View File

@ -32,11 +32,12 @@ class Awaiter : public std::enable_shared_from_this<Awaiter>
return done_;
}
virtual void DoResume() {};
protected:
std::list<std::weak_ptr<Awaiter>> notifyers_;
void Await(std::shared_ptr<Awaiter> notifyer);
virtual void DoAwait() = 0;
virtual void DoResume() {};
private:
bool done_ = false;