1
This commit is contained in:
parent
2ddbc831ec
commit
97fb0f0aa6
@ -7,6 +7,20 @@ void CoMgr::Init()
|
||||
{
|
||||
INIT_LIST_HEAD(&co_list_);
|
||||
INIT_LIST_HEAD(&exec_list_);
|
||||
CreateCo
|
||||
(
|
||||
[] (Coroutine* co)
|
||||
{
|
||||
a8::XPrintf("call 1\n", {});
|
||||
a8::XPrintf("call 2\n", {});
|
||||
});
|
||||
CreateCo
|
||||
(
|
||||
[] (Coroutine* co)
|
||||
{
|
||||
a8::XPrintf("call 10\n", {});
|
||||
a8::XPrintf("call 11\n", {});
|
||||
});
|
||||
}
|
||||
|
||||
void CoMgr::UnInit()
|
||||
@ -26,7 +40,7 @@ void CoMgr::Update()
|
||||
|
||||
std::weak_ptr<Coroutine> CoMgr::CreateCo(std::function<void(Coroutine*)> cb)
|
||||
{
|
||||
auto co = std::make_shared<Coroutine>(cb);
|
||||
std::shared_ptr<Coroutine> co(new Coroutine(cb));
|
||||
co->hold_self_ = co;
|
||||
return co;
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ class Promise : public Awaiter
|
||||
class Coroutine : public Awaiter, public std::enable_shared_from_this<Coroutine>
|
||||
{
|
||||
public:
|
||||
Coroutine(std::function<void(Coroutine*)> cb);
|
||||
~Coroutine();
|
||||
|
||||
void CoSuspend();
|
||||
@ -25,6 +24,7 @@ class Coroutine : public Awaiter, public std::enable_shared_from_this<Coroutine>
|
||||
void CoAwait(Awaiter* awaiter);
|
||||
|
||||
private:
|
||||
Coroutine(std::function<void(Coroutine*)> cb);
|
||||
|
||||
bool Exec();
|
||||
void Attach();
|
||||
|
@ -13,15 +13,6 @@
|
||||
|
||||
void PlayerMgr::Init()
|
||||
{
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
}
|
||||
Coroutine co
|
||||
(
|
||||
[] (Coroutine* co)
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void PlayerMgr::UnInit()
|
||||
|
Loading…
x
Reference in New Issue
Block a user