This commit is contained in:
aozhiwei 2023-05-27 15:07:14 +08:00
parent 1d7e8a1087
commit aaac15a155
2 changed files with 8 additions and 13 deletions

View File

@ -15,13 +15,18 @@ void CoMgr::Init()
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
co->CoYield(); co->CoYield();
co->CoAwait(co->Sleep(1000)); co->CoAwait(co->Sleep(1000));
co->CoAwait(co->Sleep(3000));
#if 0
co->CoAwait(CreateCo co->CoAwait(CreateCo
( (
[i] (Coroutine* co) [i] (Coroutine* co)
{ {
a8::XPrintf("call subco A %d %d\n", {i, a8::XGetTickCount()}); a8::XPrintf("call subco A1 %d %d\n", {i, a8::XGetTickCount()});
co->CoAwait(co->Sleep(3000)); //co->CoAwait(co->Sleep(3000));
///co->Sleep(3000);
a8::XPrintf("call subco A2 %d %d\n", {i, a8::XGetTickCount()});
}).lock()); }).lock());
#endif
a8::XPrintf("call A %d %d\n", {i, a8::XGetTickCount()}); a8::XPrintf("call A %d %d\n", {i, a8::XGetTickCount()});
} }
}); });

View File

@ -48,11 +48,7 @@ Coroutine::Coroutine(std::function<void(Coroutine*)> cb)
CallEnter(sink); CallEnter(sink);
cb_(this); cb_(this);
CallExit(sink); CallExit(sink);
for (auto notifyer : notifyers_) { DoDone();
if (!notifyer.expired()) {
notifyer.lock()->DoResume();
}
}
}); });
} }
@ -125,12 +121,6 @@ void Coroutine::CallExit(boost::coroutines2::coroutine<void>::push_type& sink)
void Coroutine::DoAwait() void Coroutine::DoAwait()
{ {
done_ = true;
for (auto notifyer : notifyers_) {
if (!notifyer.expired()) {
notifyer.lock()->DoResume();
}
}
} }
void Coroutine::DoResume() void Coroutine::DoResume()