This commit is contained in:
aozhiwei 2023-05-24 21:31:53 +08:00
parent fd1386e1be
commit beed72f3a9
2 changed files with 5 additions and 10 deletions

View File

@ -64,12 +64,14 @@ std::shared_ptr<a8::Results> Coroutine::CoAwait(Awaiter& awaiter)
std::shared_ptr<a8::Results> Coroutine::CoAwait(Awaiter* awaiter) std::shared_ptr<a8::Results> Coroutine::CoAwait(Awaiter* awaiter)
{ {
CoSuspend(); CoSuspend();
#if 0
awaiter->Await awaiter->Await
( (
[] () [] ()
{ {
}); });
#endif
CoYield(); CoYield();
while (!awaiter->Done()) { while (!awaiter->Done()) {
CoYield(); CoYield();
@ -99,8 +101,3 @@ void Coroutine::CallExit(boost::coroutines2::coroutine<void>::push_type& sink)
{ {
sink_ = nullptr; sink_ = nullptr;
} }
void Coroutine::Await(std::function<void()> cb)
{
}

View File

@ -18,7 +18,7 @@ namespace a8
}; };
} }
class Awaiter class Awaiter : public std::enable_shared_from_this<Awaiter>
{ {
public: public:
@ -34,7 +34,7 @@ class Awaiter
protected: protected:
virtual void Await(std::function<void()> cb) virtual void Await(std::shared_ptr<Awaiter> parent)
{ {
} }
@ -51,7 +51,7 @@ class Promise : public Awaiter
}; };
class Coroutine : public Awaiter, public std::enable_shared_from_this<Coroutine> class Coroutine : public Awaiter
{ {
public: public:
~Coroutine(); ~Coroutine();
@ -71,8 +71,6 @@ class Coroutine : public Awaiter, public std::enable_shared_from_this<Coroutine>
void CallEnter(boost::coroutines2::coroutine<void>::push_type& sink); void CallEnter(boost::coroutines2::coroutine<void>::push_type& sink);
void CallExit(boost::coroutines2::coroutine<void>::push_type& sink); void CallExit(boost::coroutines2::coroutine<void>::push_type& sink);
virtual void Await(std::function<void()> cb) override;
private: private:
list_head co_entry_; list_head co_entry_;
list_head exec_entry_; list_head exec_entry_;