16 #if defined(LIBCOPP_MACRO_ENABLE_STD_COROUTINE) && LIBCOPP_MACRO_ENABLE_STD_COROUTINE
20 static copp::callable_future<int> call_for_await_cotask(my_task_t::ptr_t t) {
22 auto ret = co_await t;
29 static int cotask_action_callback(
void*) {
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");
virtual int yield(void **priv_data)=0
LIBCOPP_COTASK_API impl::task_impl * get_task() LIBCOPP_MACRO_NOEXCEPT
get current running task