1
This commit is contained in:
parent
1632a294c9
commit
c1a4452086
@ -5,12 +5,13 @@
|
|||||||
#include "coroutine.h"
|
#include "coroutine.h"
|
||||||
#include "comgr.h"
|
#include "comgr.h"
|
||||||
|
|
||||||
void Awaiter::Await(std::shared_ptr<Awaiter> parent)
|
void Awaiter::Await(std::shared_ptr<Awaiter> notifyer)
|
||||||
{
|
{
|
||||||
|
notifyers_.push_back(notifyer);
|
||||||
|
DoAwait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Promise::Await(std::shared_ptr<Awaiter> parent)
|
void Promise::DoAwait()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -107,7 +108,7 @@ void Coroutine::CallExit(boost::coroutines2::coroutine<void>::push_type& sink)
|
|||||||
sink_ = nullptr;
|
sink_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Coroutine::Await(std::shared_ptr<Awaiter> parent)
|
void Coroutine::DoAwait()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,9 @@ class Awaiter : public std::enable_shared_from_this<Awaiter>
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
std::list<std::weak_ptr<Awaiter>> notifyers_;
|
||||||
virtual void Await(std::shared_ptr<Awaiter> parent);
|
void Await(std::shared_ptr<Awaiter> notifyer);
|
||||||
|
virtual void DoAwait() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool done_ = false;
|
bool done_ = false;
|
||||||
@ -47,10 +48,8 @@ class Promise : public Awaiter
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void Await(std::shared_ptr<Awaiter> parent) override;
|
virtual void DoAwait() override;
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<Awaiter> parent_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Coroutine : public Awaiter
|
class Coroutine : public Awaiter
|
||||||
@ -71,7 +70,7 @@ class Coroutine : public Awaiter
|
|||||||
void Deatch();
|
void Deatch();
|
||||||
void CallEnter(boost::coroutines2::coroutine<void>::push_type& sink);
|
void CallEnter(boost::coroutines2::coroutine<void>::push_type& sink);
|
||||||
void CallExit(boost::coroutines2::coroutine<void>::push_type& sink);
|
void CallExit(boost::coroutines2::coroutine<void>::push_type& sink);
|
||||||
virtual void Await(std::shared_ptr<Awaiter> parent) override;
|
virtual void DoAwait() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
list_head co_entry_;
|
list_head co_entry_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user