diff options
| author | Tyge Løvset <[email protected]> | 2023-07-02 22:01:46 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-07-02 23:18:10 +0200 |
| commit | e25dec033773ab713a7593a923e2c83745be0b9a (patch) | |
| tree | 174c9edfee09fb90b18ac17661cc9a8f291fa83c /misc/examples/triples.c | |
| parent | fc43b14f706f22e3933b3d225819ea68f7ce2679 (diff) | |
| download | STC-modified-e25dec033773ab713a7593a923e2c83745be0b9a.tar.gz STC-modified-e25dec033773ab713a7593a923e2c83745be0b9a.zip | |
Update in coroutine API. cco_yield, cco_await, cco_await_on, cco_block_on has changed. cco_final: renamed => cco_cleanup:
Reverted i_retain template param back to => i_more.
Diffstat (limited to 'misc/examples/triples.c')
| -rw-r--r-- | misc/examples/triples.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/misc/examples/triples.c b/misc/examples/triples.c index 17e3d40b..a8ca6b47 100644 --- a/misc/examples/triples.c +++ b/misc/examples/triples.c @@ -32,7 +32,7 @@ struct triples { int cco_state; }; -void triples_coro(struct triples* t) { +int triples_coro(struct triples* t) { cco_routine(t) { t->count = 0; for (t->c = 5; t->size; ++t->c) { @@ -46,9 +46,10 @@ void triples_coro(struct triples* t) { } } } - cco_final: + cco_cleanup: puts("done"); } + return 0; } int main() @@ -57,11 +58,10 @@ int main() triples_vanilla(5); puts("\nCoroutine triples:"); - struct triples t = {INT32_MAX}; + struct triples t = {.size=INT32_MAX}; int n = 0; - while (!cco_done(&t)) { - triples_coro(&t); + while (triples_coro(&t)) { if (gcd(t.a, t.b) > 1) continue; if (t.c < 100) |
