From beed72f3a9fb3192286a4f8fbd3e00c1b1b6903e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 24 May 2023 21:31:53 +0800 Subject: [PATCH] 1 --- server/robotserver/coroutine.cc | 7 ++----- server/robotserver/coroutine.h | 8 +++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/server/robotserver/coroutine.cc b/server/robotserver/coroutine.cc index b67cc212..a4e44d28 100644 --- a/server/robotserver/coroutine.cc +++ b/server/robotserver/coroutine.cc @@ -64,12 +64,14 @@ std::shared_ptr Coroutine::CoAwait(Awaiter& awaiter) std::shared_ptr Coroutine::CoAwait(Awaiter* awaiter) { CoSuspend(); + #if 0 awaiter->Await ( [] () { }); + #endif CoYield(); while (!awaiter->Done()) { CoYield(); @@ -99,8 +101,3 @@ void Coroutine::CallExit(boost::coroutines2::coroutine::push_type& sink) { sink_ = nullptr; } - -void Coroutine::Await(std::function cb) -{ - -} diff --git a/server/robotserver/coroutine.h b/server/robotserver/coroutine.h index 02556207..c89fe79a 100644 --- a/server/robotserver/coroutine.h +++ b/server/robotserver/coroutine.h @@ -18,7 +18,7 @@ namespace a8 }; } -class Awaiter +class Awaiter : public std::enable_shared_from_this { public: @@ -34,7 +34,7 @@ class Awaiter protected: - virtual void Await(std::function cb) + virtual void Await(std::shared_ptr parent) { } @@ -51,7 +51,7 @@ class Promise : public Awaiter }; -class Coroutine : public Awaiter, public std::enable_shared_from_this +class Coroutine : public Awaiter { public: ~Coroutine(); @@ -71,8 +71,6 @@ class Coroutine : public Awaiter, public std::enable_shared_from_this void CallEnter(boost::coroutines2::coroutine::push_type& sink); void CallExit(boost::coroutines2::coroutine::push_type& sink); - virtual void Await(std::function cb) override; - private: list_head co_entry_; list_head exec_entry_;