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 ...");
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");
virtual int yield(void **priv_data)=0
导入继承关系约束 Licensed under the MIT licenses.
#define EXPLICIT_UNUSED_ATTR
maybe_unused, 标记忽略unused警告 usage: EXPLICIT_UNUSED_ATTR int a; class EXPLICIT_UNUSED_ATTR a; EXPLICIT_...
LIBCOPP_COTASK_API impl::task_impl * get_task() LIBCOPP_MACRO_NOEXCEPT
get current running task