1
This commit is contained in:
parent
beed72f3a9
commit
dc6b6ac09d
@ -5,6 +5,11 @@
|
|||||||
#include "coroutine.h"
|
#include "coroutine.h"
|
||||||
#include "comgr.h"
|
#include "comgr.h"
|
||||||
|
|
||||||
|
void Awaiter::Await(std::shared_ptr<Awaiter> parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Coroutine::Coroutine(std::function<void(Coroutine*)> cb)
|
Coroutine::Coroutine(std::function<void(Coroutine*)> cb)
|
||||||
{
|
{
|
||||||
INIT_LIST_HEAD(&co_entry_);
|
INIT_LIST_HEAD(&co_entry_);
|
||||||
@ -56,12 +61,7 @@ void Coroutine::CoYield()
|
|||||||
(*sink_)();
|
(*sink_)();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<a8::Results> Coroutine::CoAwait(Awaiter& awaiter)
|
std::shared_ptr<a8::Results> Coroutine::CoAwait(std::shared_ptr<Awaiter> awaiter)
|
||||||
{
|
|
||||||
return CoAwait(&awaiter);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<a8::Results> Coroutine::CoAwait(Awaiter* awaiter)
|
|
||||||
{
|
{
|
||||||
CoSuspend();
|
CoSuspend();
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -22,24 +22,22 @@ class Awaiter : public std::enable_shared_from_this<Awaiter>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual std::shared_ptr<a8::Results> GetResult()
|
std::shared_ptr<a8::Results> GetResult()
|
||||||
{
|
{
|
||||||
return results_;
|
return results_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Done()
|
bool Done()
|
||||||
{
|
{
|
||||||
return done_;
|
return done_;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void Await(std::shared_ptr<Awaiter> parent)
|
virtual void Await(std::shared_ptr<Awaiter> parent);
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::shared_ptr<Awaiter> parent_;
|
||||||
bool done_ = false;
|
bool done_ = false;
|
||||||
std::shared_ptr<a8::Results> results_;
|
std::shared_ptr<a8::Results> results_;
|
||||||
std::function<void()> cb_;
|
std::function<void()> cb_;
|
||||||
@ -59,8 +57,7 @@ class Coroutine : public Awaiter
|
|||||||
void CoSuspend();
|
void CoSuspend();
|
||||||
void CoResume();
|
void CoResume();
|
||||||
void CoYield();
|
void CoYield();
|
||||||
std::shared_ptr<a8::Results> CoAwait(Awaiter& awaiter);
|
std::shared_ptr<a8::Results> CoAwait(std::shared_ptr<Awaiter> awaiter);
|
||||||
std::shared_ptr<a8::Results> CoAwait(Awaiter* awaiter);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Coroutine(std::function<void(Coroutine*)> cb);
|
Coroutine(std::function<void(Coroutine*)> cb);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user