24#if defined(LIBCOTASK_MACRO_ENABLED)
32 my_task_t::ptr_t first_task = my_task_t::create([&]() {
33 puts(
"|first task running and will be yield ...");
34 cotask::this_task::get_task()->yield();
35 puts(
"|first task resumed ...");
36 printf(
"test code already reset => %d\n", ++test_code);
42 puts(
"|second task running...");
43 printf(
"test code should be inited 128 => %d\n", test_code);
46 puts(
"|haha ... this is the third task.");
47 printf(
"test code is the same => %d\n", ++test_code);
48 return "return value will be ignored";
53 printf(
"test code is %d\n", ++test_code);
54 assert(&test_code == priv_data);
65 first_task->then([]() {
66 puts(
"this will run immediately.");
70 my_task_t::ptr_t await_task = my_task_t::create([&]() {
71 puts(
"await_task for first_task.");
74 await_task->await_task(first_task);
76 printf(
"|task start twice will failed: %d\n", first_task->start());
77 printf(
"|test_code end with %d\n", test_code);
82 puts(
"this sample require cotask enabled");
#define LIBCOPP_EXPLICIT_UNUSED_ATTR
maybe_unused attribute usage: LIBCOPP_EXPLICIT_UNUSED_ATTR int a; class LIBCOPP_EXPLICIT_UNUSED_ATTR ...