summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/coroutines/cotasks2.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-08-01 16:47:38 +0200
committerTyge Løvset <[email protected]>2023-08-01 18:09:40 +0200
commit94391527ef50cbee073a4b427f6fe839c010ecb1 (patch)
treef4d48b7efd6a11d94d08c4ef2ee599601b949dbb /misc/examples/coroutines/cotasks2.c
parent6354a597892e84baa6c3a99b98f2c7acaf33a99d (diff)
downloadSTC-modified-94391527ef50cbee073a4b427f6fe839c010ecb1.tar.gz
STC-modified-94391527ef50cbee073a4b427f6fe839c010ecb1.zip
Last minute API change for coroutines before V4.3 release:
- Renamed cco_xxxx_await() => cco_await_xxxx() (call, task, sem, timer) - Renamed cco_xxxx_blocking() => cco_blocking_xxxx() (call, task) - Renamed cco_task_resume() => cco_resume_task() - Simplified cco_blocking_call()
Diffstat (limited to 'misc/examples/coroutines/cotasks2.c')
-rw-r--r--misc/examples/coroutines/cotasks2.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/misc/examples/coroutines/cotasks2.c b/misc/examples/coroutines/cotasks2.c
index 4fdf98d9..d77a28bc 100644
--- a/misc/examples/coroutines/cotasks2.c
+++ b/misc/examples/coroutines/cotasks2.c
@@ -15,7 +15,7 @@ int next_value(struct next_value* co, cco_runtime* rt)
{
cco_routine (co) {
while (true) {
- cco_timer_await(&co->tm, 1 + rand() % 2);
+ cco_await_timer(&co->tm, 1 + rand() % 2);
co->val = rand();
cco_yield();
}
@@ -46,7 +46,7 @@ int produce_items(struct produce_items* p, cco_runtime* rt)
while (true)
{
// await for next CCO_YIELD (or CCO_DONE) in next_value
- cco_task_await(&p->next, rt, CCO_YIELD);
+ cco_await_task(&p->next, rt, CCO_YIELD);
cstr_printf(&p->str, "item %d", p->next.val);
print_time();
printf("produced %s\n", cstr_str(&p->str));
@@ -75,14 +75,14 @@ int consume_items(struct consume_items* c, cco_runtime* rt)
for (c->i = 1; c->i <= c->n; ++c->i)
{
printf("consume #%d\n", c->i);
- cco_task_await(&c->produce, rt, CCO_YIELD);
+ cco_await_task(&c->produce, rt, CCO_YIELD);
print_time();
printf("consumed %s\n", cstr_str(&c->produce.str));
}
cco_cleanup:
cco_stop(&c->produce);
- cco_task_resume(&c->produce, rt);
+ cco_resume_task(&c->produce, rt);
puts("done consume");
}
return 0;
@@ -94,5 +94,5 @@ int main(void)
.cco_func = consume_items,
.n = 5,
};
- cco_task_blocking(&consume);
+ cco_blocking_task(&consume);
}