13 typedef copp::stack_pool<copp::allocator::default_statck_allocator>
stack_pool_t;
18 using coroutine_type = copp::coroutine_context_container<stack_allocator_type>;
28 #if defined(LIBCOTASK_MACRO_ENABLED)
31 std::cout <<
"stack pool=> used stack number: " <<
global_stack_pool->get_limit().used_stack_number
34 <<
", free stack size: " <<
global_stack_pool->get_limit().free_stack_size << std::endl;
38 sample_task_t::ptr_t co_task = sample_task_t::create(
40 std::cout <<
"task " << cotask::this_task::get<sample_task_t>()->get_id() <<
" started" << std::endl;
42 std::cout <<
"task " << cotask::this_task::get<sample_task_t>()->get_id() <<
" resumed" << std::endl;
48 std::cerr <<
"create coroutine task with stack pool failed" << std::endl;
52 std::cout <<
"stack pool=> used stack number: " <<
global_stack_pool->get_limit().used_stack_number
55 <<
", free stack size: " <<
global_stack_pool->get_limit().free_stack_size << std::endl;
60 std::cout <<
"stack pool=> used stack number: " <<
global_stack_pool->get_limit().used_stack_number
63 <<
", free stack size: " <<
global_stack_pool->get_limit().free_stack_size << std::endl;
67 sample_task_t::ptr_t co_another_task = sample_task_t::create(
69 std::cout <<
"task " << cotask::this_task::get<sample_task_t>()->get_id() <<
" started" << std::endl;
71 std::cout <<
"task " << cotask::this_task::get<sample_task_t>()->get_id() <<
" resumed" << std::endl;
76 if (!co_another_task) {
77 std::cerr <<
"create coroutine task with stack pool failed" << std::endl;
84 std::cout <<
"stack pool=> used stack number: " <<
global_stack_pool->get_limit().used_stack_number
87 <<
", free stack size: " <<
global_stack_pool->get_limit().free_stack_size << std::endl;
89 std::cerr <<
"this sample require cotask enabled." << std::endl;
virtual int yield(void **priv_data)=0
LIBCOPP_COTASK_API impl::task_impl * get_task() LIBCOPP_MACRO_NOEXCEPT
get current running task
static stack_pool_t::ptr_t global_stack_pool
copp::stack_pool< copp::allocator::default_statck_allocator > stack_pool_t
cotask::task< sample_macro_coroutine > sample_task_t
copp::allocator::stack_allocator_pool< stack_pool_t > stack_allocator_type
copp::coroutine_context_container< stack_allocator_type > coroutine_type