diff options
Diffstat (limited to 'misc')
| -rw-r--r-- | misc/examples/coroutines/cointerleave.c | 2 | ||||
| -rw-r--r-- | misc/examples/coroutines/coread.c | 2 | ||||
| -rw-r--r-- | misc/examples/coroutines/coroutines.c | 8 | ||||
| -rw-r--r-- | misc/examples/coroutines/cotasks1.c | 4 | ||||
| -rw-r--r-- | misc/examples/coroutines/cotasks2.c | 10 | ||||
| -rw-r--r-- | misc/examples/coroutines/dining_philosophers.c | 8 | ||||
| -rw-r--r-- | misc/examples/coroutines/filetask.c | 6 | ||||
| -rw-r--r-- | misc/examples/coroutines/triples.c | 2 |
8 files changed, 21 insertions, 21 deletions
diff --git a/misc/examples/coroutines/cointerleave.c b/misc/examples/coroutines/cointerleave.c index f3710ba3..80494176 100644 --- a/misc/examples/coroutines/cointerleave.c +++ b/misc/examples/coroutines/cointerleave.c @@ -49,7 +49,7 @@ void Use(void) struct Generator g = {{&a}, {&b}}; - cco_call_blocking(interleaved(&g)) { + cco_blocking_call(interleaved(&g)) { printf("%d ", g.value); } puts(""); diff --git a/misc/examples/coroutines/coread.c b/misc/examples/coroutines/coread.c index ebaaf19d..359ca85d 100644 --- a/misc/examples/coroutines/coread.c +++ b/misc/examples/coroutines/coread.c @@ -33,7 +33,7 @@ int main(void) { struct file_read g = {__FILE__}; int n = 0; - cco_call_blocking(file_read(&g)) + cco_blocking_call(file_read(&g)) { printf("%3d %s\n", ++n, cstr_str(&g.line)); //if (n == 10) cco_stop(&g); diff --git a/misc/examples/coroutines/coroutines.c b/misc/examples/coroutines/coroutines.c index 489c3ed6..e642a823 100644 --- a/misc/examples/coroutines/coroutines.c +++ b/misc/examples/coroutines/coroutines.c @@ -84,13 +84,13 @@ struct combined { int combined(struct combined* g) { cco_routine(g) { - cco_call_await(prime(&g->prm)); - cco_call_await(fibonacci(&g->fib)); + cco_await_call(prime(&g->prm)); + cco_await_call(fibonacci(&g->fib)); // Reuse the g->prm context and extend the count: g->prm.count = 8, g->prm.result += 2; cco_reset(&g->prm); - cco_call_await(prime(&g->prm)); + cco_await_call(prime(&g->prm)); cco_cleanup: puts("final combined"); @@ -103,7 +103,7 @@ int main(void) struct combined c = {.prm={.count=8}, .fib={14}}; int res; - cco_call_blocking(combined(&c), &res) { + cco_blocking_call(combined(&c), &res) { if (res == CCO_YIELD) printf("Prime(%d)=%lld, Fib(%d)=%lld\n", c.prm.idx, c.prm.result, diff --git a/misc/examples/coroutines/cotasks1.c b/misc/examples/coroutines/cotasks1.c index e4afbe2b..230bd62b 100644 --- a/misc/examples/coroutines/cotasks1.c +++ b/misc/examples/coroutines/cotasks1.c @@ -16,7 +16,7 @@ int next_value(struct next_value* co) { 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(); } @@ -88,7 +88,7 @@ int main(void) struct consume_items consume = {.n=5}; int count = 0; - cco_call_blocking(consume_items(&consume, &produce)) + cco_blocking_call(consume_items(&consume, &produce)) { ++count; //cco_sleep(0.001); 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); } diff --git a/misc/examples/coroutines/dining_philosophers.c b/misc/examples/coroutines/dining_philosophers.c index abe09204..f7edf815 100644 --- a/misc/examples/coroutines/dining_philosophers.c +++ b/misc/examples/coroutines/dining_philosophers.c @@ -34,15 +34,15 @@ int philosopher(struct Philosopher* p) while (1) { duration = 1.0 + crandf()*2.0; printf("Philosopher %d is thinking for %.0f minutes...\n", p->id, duration*10); - cco_timer_await(&p->tm, duration); + cco_await_timer(&p->tm, duration); printf("Philosopher %d is hungry...\n", p->id); - cco_sem_await(p->left_fork); - cco_sem_await(p->right_fork); + cco_await_sem(p->left_fork); + cco_await_sem(p->right_fork); duration = 0.5 + crandf(); printf("Philosopher %d is eating for %.0f minutes...\n", p->id, duration*10); - cco_timer_await(&p->tm, duration); + cco_await_timer(&p->tm, duration); cco_sem_release(p->left_fork); cco_sem_release(p->right_fork); diff --git a/misc/examples/coroutines/filetask.c b/misc/examples/coroutines/filetask.c index bfce7810..28292801 100644 --- a/misc/examples/coroutines/filetask.c +++ b/misc/examples/coroutines/filetask.c @@ -21,7 +21,7 @@ int file_read(struct file_read* co, cco_runtime* rt) while (true) { // emulate async io: await 10ms per line - cco_timer_await(&co->tm, 0.003); + cco_await_timer(&co->tm, 0.003); if (!cstr_getline(&co->line, co->fp)) break; @@ -50,7 +50,7 @@ int count_line(struct count_line* co, cco_runtime* rt) while (true) { // await for next CCO_YIELD (or CCO_DONE) in file_read() - cco_task_await(&co->reader, rt, CCO_YIELD); + cco_await_task(&co->reader, rt, CCO_YIELD); if (rt->result == CCO_DONE) break; co->lineCount += 1; cco_yield(); @@ -73,7 +73,7 @@ int main(void) // Execute coroutine as top-level blocking int loop = 0; - cco_task_blocking(&countTask) { ++loop; } + cco_blocking_task(&countTask) { ++loop; } printf("line count = %d\n", countTask.lineCount); printf("exec count = %d\n", loop); diff --git a/misc/examples/coroutines/triples.c b/misc/examples/coroutines/triples.c index 9fd771ce..22914c2b 100644 --- a/misc/examples/coroutines/triples.c +++ b/misc/examples/coroutines/triples.c @@ -64,7 +64,7 @@ int main(void) struct triples t = {.max_c = 100}; int n = 0; - cco_call_blocking(triples_coro(&t)) { + cco_blocking_call(triples_coro(&t)) { if (gcd(t.a, t.b) > 1) continue; if (++n <= 20) |
