16#if defined(LIBCOPP_MACRO_ENABLE_STD_COROUTINE) && LIBCOPP_MACRO_ENABLE_STD_COROUTINE
20static copp::callable_future<int> call_for_await_cotask(my_task_t::ptr_t t) {
22 auto ret =
co_await t;
29static int cotask_action_callback(
void*) {
32 cotask::this_task::get_task()->yield(&ptr);
34 ret = *
reinterpret_cast<int*
>(ptr);
40 my_task_t::ptr_t co_task = my_task_t::create(cotask_action_callback);
42 auto t = call_for_await_cotask(co_task);
46 co_task->resume(
reinterpret_cast<void*
>(&res));
48 std::cout <<
"co_await a cotask::task and get result: " << t.get_internal_promise().data() << std::endl;
53 puts(
"this sample require cotask enabled and compiler support c++20 coroutine");