39 lines
707 B
C++
39 lines
707 B
C++
#include <a8/a8.h>
|
|
|
|
#include <f8/f8.h>
|
|
#include <f8/comgr.h>
|
|
#include <f8/coroutine.h>
|
|
|
|
namespace f8
|
|
{
|
|
|
|
void CoMgr::Init()
|
|
{
|
|
INIT_LIST_HEAD(&co_list_);
|
|
INIT_LIST_HEAD(&exec_list_);
|
|
}
|
|
|
|
void CoMgr::UnInit()
|
|
{
|
|
|
|
}
|
|
|
|
void CoMgr::Update()
|
|
{
|
|
Coroutine *co = nullptr, *tmp = nullptr;
|
|
list_for_each_entry_safe(co, tmp, &exec_list_, exec_entry_) {
|
|
if (!co->Exec()) {
|
|
co->hold_self_ = nullptr;
|
|
}
|
|
}
|
|
}
|
|
|
|
std::weak_ptr<Coroutine> CoMgr::CreateCo(std::function<void(Coroutine*)> cb)
|
|
{
|
|
std::shared_ptr<Coroutine> co(new Coroutine(cb));
|
|
co->hold_self_ = co;
|
|
return co;
|
|
}
|
|
|
|
}
|