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(&co_list_);
|
||||||
INIT_LIST_HEAD(&exec_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()
|
void CoMgr::UnInit()
|
||||||
@ -26,7 +40,7 @@ void CoMgr::Update()
|
|||||||
|
|
||||||
std::weak_ptr<Coroutine> CoMgr::CreateCo(std::function<void(Coroutine*)> cb)
|
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;
|
co->hold_self_ = co;
|
||||||
return co;
|
return co;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ class Promise : public Awaiter
|
|||||||
class Coroutine : public Awaiter, public std::enable_shared_from_this<Coroutine>
|
class Coroutine : public Awaiter, public std::enable_shared_from_this<Coroutine>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Coroutine(std::function<void(Coroutine*)> cb);
|
|
||||||
~Coroutine();
|
~Coroutine();
|
||||||
|
|
||||||
void CoSuspend();
|
void CoSuspend();
|
||||||
@ -25,6 +24,7 @@ class Coroutine : public Awaiter, public std::enable_shared_from_this<Coroutine>
|
|||||||
void CoAwait(Awaiter* awaiter);
|
void CoAwait(Awaiter* awaiter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Coroutine(std::function<void(Coroutine*)> cb);
|
||||||
|
|
||||||
bool Exec();
|
bool Exec();
|
||||||
void Attach();
|
void Attach();
|
||||||
|
@ -13,15 +13,6 @@
|
|||||||
|
|
||||||
void PlayerMgr::Init()
|
void PlayerMgr::Init()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
|
|
||||||
}
|
|
||||||
Coroutine co
|
|
||||||
(
|
|
||||||
[] (Coroutine* co)
|
|
||||||
{
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerMgr::UnInit()
|
void PlayerMgr::UnInit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user