From 97fb0f0aa66ce984b454e7aa7d395aeedc25fda7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 18 May 2023 23:00:34 +0800 Subject: [PATCH] 1 --- server/robotserver/comgr.cc | 16 +++++++++++++++- server/robotserver/coroutine.h | 2 +- server/robotserver/playermgr.cc | 9 --------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/server/robotserver/comgr.cc b/server/robotserver/comgr.cc index 4deb4ad9..3f5a6cba 100644 --- a/server/robotserver/comgr.cc +++ b/server/robotserver/comgr.cc @@ -7,6 +7,20 @@ void CoMgr::Init() { INIT_LIST_HEAD(&co_list_); INIT_LIST_HEAD(&exec_list_); + CreateCo + ( + [] (Coroutine* co) + { + a8::XPrintf("call 1\n", {}); + a8::XPrintf("call 2\n", {}); + }); + CreateCo + ( + [] (Coroutine* co) + { + a8::XPrintf("call 10\n", {}); + a8::XPrintf("call 11\n", {}); + }); } void CoMgr::UnInit() @@ -26,7 +40,7 @@ void CoMgr::Update() std::weak_ptr CoMgr::CreateCo(std::function cb) { - auto co = std::make_shared(cb); + std::shared_ptr co(new Coroutine(cb)); co->hold_self_ = co; return co; } diff --git a/server/robotserver/coroutine.h b/server/robotserver/coroutine.h index 410b2601..da0cc9ea 100644 --- a/server/robotserver/coroutine.h +++ b/server/robotserver/coroutine.h @@ -15,7 +15,6 @@ class Promise : public Awaiter class Coroutine : public Awaiter, public std::enable_shared_from_this { public: - Coroutine(std::function cb); ~Coroutine(); void CoSuspend(); @@ -25,6 +24,7 @@ class Coroutine : public Awaiter, public std::enable_shared_from_this void CoAwait(Awaiter* awaiter); private: + Coroutine(std::function cb); bool Exec(); void Attach(); diff --git a/server/robotserver/playermgr.cc b/server/robotserver/playermgr.cc index d9da884c..320525fd 100644 --- a/server/robotserver/playermgr.cc +++ b/server/robotserver/playermgr.cc @@ -13,15 +13,6 @@ void PlayerMgr::Init() { - for (int i = 0; i < 10; i++) { - - } - Coroutine co - ( - [] (Coroutine* co) - { - - }); } void PlayerMgr::UnInit()