This commit is contained in:
aozhiwei 2023-05-16 22:41:05 +08:00
parent 1b43f53bb2
commit c8f08c2975
3 changed files with 18 additions and 3 deletions

View File

@ -127,6 +127,7 @@ target_link_libraries(
hiredis
tinyxml2
backtrace
boost_context
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")

View File

@ -2,9 +2,23 @@
#include "coroutine.h"
Coroutine::Coroutine(std::function<void(Coroutine* co)> cb)
Coroutine::Coroutine(std::function<void(Coroutine*)> cb)
{
cb_ = cb;
#if 0
source_ = std::make_shared<boost::coroutines2::coroutine<void>::pull_type>
(
[&] (boost::coroutines2::coroutine<void>::pull_type& sink)
{
});
#endif
boost::coroutines2::coroutine<void>::pull_type source
(
[&] (boost::coroutines2::coroutine<void>::push_type& sink)
{
});
}
void Coroutine::CoSuspend()

View File

@ -16,7 +16,7 @@ class Coroutine : public Awaiter
{
public:
Coroutine(std::function<void(Coroutine* co)> cb);
Coroutine(std::function<void(Coroutine*)> cb);
void CoSuspend();
void CoResume();
@ -24,6 +24,6 @@ class Coroutine : public Awaiter
void CoAwait(Awaiter* awaiter);
private:
boost::coroutines2::coroutine<void> coro_;
std::shared_ptr<boost::coroutines2::coroutine<void>::pull_type> source_;
std::function<void(Coroutine* co)> cb_;
};