diff --git a/server/robotserver/app.cc b/server/robotserver/app.cc index cc2bd83b..1e12a3ef 100644 --- a/server/robotserver/app.cc +++ b/server/robotserver/app.cc @@ -19,6 +19,7 @@ #include "handlermgr.h" #include "httpproxy.h" #include "playermgr.h" +#include "comgr.h" #include "ss_msgid.pb.h" #include "ss_proto.pb.h" @@ -89,6 +90,7 @@ bool App::Init(int argc, char* argv[]) HandlerMgr::Instance()->Init(); f8::Timer::Instance()->Init(); f8::TGLog::Instance()->Init(a8::Format(PROJ_NAME_FMT, {GAME_ID}), false, 0); + CoMgr::Instance()->Init(); f8::HttpClientPool::Instance()->Init(MAX_ALL_HTTP_NUM, MAX_SYS_HTTP_NUM, MAX_USER_HTTP_NUM); f8::BtMgr::Instance()->Init("exported"); #ifdef DEBUG @@ -132,6 +134,7 @@ void App::UnInit() f8::BtMgr::Instance()->UnInit(); f8::HttpClientPool::Instance()->UnInit(); HandlerMgr::Instance()->UnInit(); + CoMgr::Instance()->UnInit(); f8::MsgQueue::Instance()->UnInit(); f8::Timer::Instance()->UnInit(); f8::TGLog::Instance()->UnInit(); @@ -203,6 +206,7 @@ void App::QuickExecute(int delta_time) void App::SlowerExecute(int delta_time) { + CoMgr::Instance()->Update(); } void App::NotifyLoopCond() diff --git a/server/robotserver/comgr.cc b/server/robotserver/comgr.cc index 64cee3b6..8d83d118 100644 --- a/server/robotserver/comgr.cc +++ b/server/robotserver/comgr.cc @@ -20,3 +20,8 @@ void CoMgr::Update() co->Exec(); } } + +std::weak_ptr CoMgr::CreateCoroutine(std::function cb) +{ + return std::make_shared(cb); +} diff --git a/server/robotserver/comgr.h b/server/robotserver/comgr.h index 8c096163..ca879688 100644 --- a/server/robotserver/comgr.h +++ b/server/robotserver/comgr.h @@ -2,6 +2,7 @@ #include +class Coroutine; class CoMgr : public a8::Singleton { @@ -15,6 +16,8 @@ class CoMgr : public a8::Singleton void UnInit(); void Update(); + std::weak_ptr CreateCoroutine(std::function cb); + private: list_head co_list_;