From c8f08c2975e7f0e89348e50673e0db68335feb16 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 16 May 2023 22:41:05 +0800 Subject: [PATCH] 1 --- server/robotserver/CMakeLists.txt | 1 + server/robotserver/coroutine.cc | 16 +++++++++++++++- server/robotserver/coroutine.h | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/server/robotserver/CMakeLists.txt b/server/robotserver/CMakeLists.txt index 0daa2e28..b9cbd2a3 100644 --- a/server/robotserver/CMakeLists.txt +++ b/server/robotserver/CMakeLists.txt @@ -127,6 +127,7 @@ target_link_libraries( hiredis tinyxml2 backtrace + boost_context ) if (CMAKE_BUILD_TYPE STREQUAL "Debug") diff --git a/server/robotserver/coroutine.cc b/server/robotserver/coroutine.cc index 8ec2b649..cccdaa9e 100644 --- a/server/robotserver/coroutine.cc +++ b/server/robotserver/coroutine.cc @@ -2,9 +2,23 @@ #include "coroutine.h" -Coroutine::Coroutine(std::function cb) +Coroutine::Coroutine(std::function cb) { cb_ = cb; + #if 0 + source_ = std::make_shared::pull_type> + ( + [&] (boost::coroutines2::coroutine::pull_type& sink) + { + + }); + #endif + boost::coroutines2::coroutine::pull_type source + ( + [&] (boost::coroutines2::coroutine::push_type& sink) + { + + }); } void Coroutine::CoSuspend() diff --git a/server/robotserver/coroutine.h b/server/robotserver/coroutine.h index 954a7aab..8da21787 100644 --- a/server/robotserver/coroutine.h +++ b/server/robotserver/coroutine.h @@ -16,7 +16,7 @@ class Coroutine : public Awaiter { public: - Coroutine(std::function cb); + Coroutine(std::function cb); void CoSuspend(); void CoResume(); @@ -24,6 +24,6 @@ class Coroutine : public Awaiter void CoAwait(Awaiter* awaiter); private: - boost::coroutines2::coroutine coro_; + std::shared_ptr::pull_type> source_; std::function cb_; };