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/coread.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/coread.c')
| -rw-r--r-- | misc/examples/coread.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/misc/examples/coread.c b/misc/examples/coread.c index 622228c0..a13f6be5 100644 --- a/misc/examples/coread.c +++ b/misc/examples/coread.c @@ -12,7 +12,7 @@ struct file_read { cstr line; }; -void file_read(struct file_read* g) +int file_read(struct file_read* g) { cco_routine(g) { g->fp = fopen(g->filename, "r"); @@ -21,18 +21,19 @@ void file_read(struct file_read* g) cco_await(!cstr_getline(&g->line, g->fp)); - cco_final: + cco_cleanup: printf("finish\n"); cstr_drop(&g->line); if (g->fp) fclose(g->fp); } + return 0; } int main(void) { struct file_read g = {__FILE__}; int n = 0; - cco_block_on(&g, file_read) + cco_block_on(file_read(&g)) { printf("%3d %s\n", ++n, cstr_str(&g.line)); //if (n == 10) cco_stop(&g); |
