15 typedef cotask::task_manager<my_task_t>
mgr_t;
28 std::cout <<
"task " << cotask::this_task::get<my_task_t>()->get_id() <<
" started" << std::endl;
30 std::cout <<
"task " << cotask::this_task::get<my_task_t>()->get_id() <<
" resumed" << std::endl;
34 std::cout <<
"task " << cotask::this_task::get<my_task_t>()->get_id() <<
" started" << std::endl;
36 std::cout <<
"task " << cotask::this_task::get<my_task_t>()->get_id() <<
" resumed" << std::endl;
40 int res =
task_mgr->add_task(co_task, 5, 0);
42 std::cerr <<
"some error: " << res << std::endl;
46 res =
task_mgr->add_task(co_another_task);
48 std::cerr <<
"some error: " << res << std::endl;
52 res =
task_mgr->start(co_task->get_id());
54 std::cerr <<
"start task " << co_task->get_id() <<
" failed, error code: " << res << std::endl;
57 res =
task_mgr->start(co_another_task->get_id());
59 std::cerr <<
"start task " << co_another_task->get_id() <<
" failed, error code: " << res << std::endl;
62 res =
task_mgr->resume(co_task->get_id());
64 std::cerr <<
"resume task " << co_task->get_id() <<
" failed, error code: " << res << std::endl;
67 res =
task_mgr->kill(co_another_task->get_id());
69 std::cerr <<
"kill task " << co_another_task->get_id() <<
" failed, error code: " << res << std::endl;
71 std::cout <<
"kill task " << co_another_task->get_id() <<
" finished." << std::endl;
virtual int yield(void **priv_data)=0
LIBCOPP_COTASK_API impl::task_impl * get_task() LIBCOPP_MACRO_NOEXCEPT
get current running task
cotask::task_manager< my_task_t > mgr_t
my_task_t::ptr_t task_ptr_type