diff --git a/server/robotserver/coroutine.cc b/server/robotserver/coroutine.cc index a4e44d28..9b048f6c 100644 --- a/server/robotserver/coroutine.cc +++ b/server/robotserver/coroutine.cc @@ -5,6 +5,11 @@ #include "coroutine.h" #include "comgr.h" +void Awaiter::Await(std::shared_ptr parent) +{ + +} + Coroutine::Coroutine(std::function cb) { INIT_LIST_HEAD(&co_entry_); @@ -56,12 +61,7 @@ void Coroutine::CoYield() (*sink_)(); } -std::shared_ptr Coroutine::CoAwait(Awaiter& awaiter) -{ - return CoAwait(&awaiter); -} - -std::shared_ptr Coroutine::CoAwait(Awaiter* awaiter) +std::shared_ptr Coroutine::CoAwait(std::shared_ptr awaiter) { CoSuspend(); #if 0 diff --git a/server/robotserver/coroutine.h b/server/robotserver/coroutine.h index c89fe79a..f40e9ee9 100644 --- a/server/robotserver/coroutine.h +++ b/server/robotserver/coroutine.h @@ -22,24 +22,22 @@ class Awaiter : public std::enable_shared_from_this { public: - virtual std::shared_ptr GetResult() + std::shared_ptr GetResult() { return results_; } - virtual bool Done() + bool Done() { return done_; } protected: - virtual void Await(std::shared_ptr parent) - { - - } + virtual void Await(std::shared_ptr parent); private: + std::shared_ptr parent_; bool done_ = false; std::shared_ptr results_; std::function cb_; @@ -59,8 +57,7 @@ class Coroutine : public Awaiter void CoSuspend(); void CoResume(); void CoYield(); - std::shared_ptr CoAwait(Awaiter& awaiter); - std::shared_ptr CoAwait(Awaiter* awaiter); + std::shared_ptr CoAwait(std::shared_ptr awaiter); private: Coroutine(std::function cb);