summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/cointerleave.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-05-04 11:51:56 +0200
committerTyge Løvset <[email protected]>2023-05-04 16:19:00 +0200
commitb03148caa1d6fc660e6e7c5986dd6fd38779bedc (patch)
tree6e4c7972437f6e8e6fddf39b0f48a2b0ace05af8 /misc/examples/cointerleave.c
parent6b23e35287f26dad63abd755c5f365b443e025a3 (diff)
downloadSTC-modified-b03148caa1d6fc660e6e7c5986dd6fd38779bedc.tar.gz
STC-modified-b03148caa1d6fc660e6e7c5986dd6fd38779bedc.zip
Updates in coroutines.h: No longer *required* with cco_final:, but only when no cleanup is needed.
Diffstat (limited to 'misc/examples/cointerleave.c')
-rw-r--r--misc/examples/cointerleave.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/misc/examples/cointerleave.c b/misc/examples/cointerleave.c
index 5bdbd257..4fe89316 100644
--- a/misc/examples/cointerleave.c
+++ b/misc/examples/cointerleave.c
@@ -16,7 +16,6 @@ static int next_value(struct GenValue* g)
cco_begin(g);
for (g->it = IVec_begin(g->v); g->it.ref; IVec_next(&g->it))
cco_yield(*g->it.ref);
- cco_final:
cco_end(0);
}
@@ -37,7 +36,6 @@ void interleaved(struct Generator* g)
g->value = next_value(&g->y);
if (!cco_done(&g->y)) cco_yield();
}
- cco_final:
cco_end();
}
@@ -48,9 +46,11 @@ void Use(void)
struct Generator g = {{&a}, {&b}};
- while (interleaved(&g), !cco_done(&g))
+ while (1) {
+ interleaved(&g);
+ if (cco_done(&g)) break;
printf("%d ", g.value);
-
+ }
puts("");
c_drop(IVec, &a, &b);
}