summaryrefslogtreecommitdiffhomepage
path: root/misc
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2023-05-09 04:40:24 +0200
committerTyge Lovset <[email protected]>2023-05-09 04:40:24 +0200
commit99d94309f31f082b505180d2cb7c1c6c2215e9f0 (patch)
treeb4dd5aec779eff711e5e3fea0d356301c3969cd2 /misc
parent2f11c7cf36690a1493344189b6a011c26ee58a9b (diff)
downloadSTC-modified-99d94309f31f082b505180d2cb7c1c6c2215e9f0.tar.gz
STC-modified-99d94309f31f082b505180d2cb7c1c6c2215e9f0.zip
reverted cco_await_done => cco_await_at.
Diffstat (limited to 'misc')
-rw-r--r--misc/examples/cointerleave.c2
-rw-r--r--misc/examples/coread.c11
-rw-r--r--misc/examples/coroutines.c2
-rw-r--r--misc/examples/scheduler.c12
4 files changed, 13 insertions, 14 deletions
diff --git a/misc/examples/cointerleave.c b/misc/examples/cointerleave.c
index 0854a741..d725989f 100644
--- a/misc/examples/cointerleave.c
+++ b/misc/examples/cointerleave.c
@@ -43,7 +43,7 @@ void Use(void)
struct Generator g = {{&a}, {&b}};
- cco_run_blocked(&g, interleaved(&g)) {
+ cco_run(&g, interleaved(&g)) {
printf("%d ", g.value);
}
puts("");
diff --git a/misc/examples/coread.c b/misc/examples/coread.c
index 0073191b..e60fb31c 100644
--- a/misc/examples/coread.c
+++ b/misc/examples/coread.c
@@ -11,29 +11,28 @@ struct file_read {
cstr line;
};
-bool file_read(struct file_read* g)
+void file_read(struct file_read* g)
{
cco_begin(g)
g->fp = fopen(g->filename, "r");
g->line = cstr_init();
- while (cstr_getline(&g->line, g->fp))
- cco_yield(false);
+ cco_await(!cstr_getline(&g->line, g->fp));
cco_final:
printf("finish\n");
cstr_drop(&g->line);
fclose(g->fp);
- cco_end(true);
+ cco_end();
}
int main(void)
{
struct file_read g = {__FILE__};
int n = 0;
- while (!file_read(&g))
+ cco_run(&g, file_read(&g))
{
printf("%3d %s\n", ++n, cstr_str(&g.line));
- //if (n == 10) cco_stop(&it);
+ //if (n == 10) cco_stop(&g);
}
}
diff --git a/misc/examples/coroutines.c b/misc/examples/coroutines.c
index 7f255dda..a7136993 100644
--- a/misc/examples/coroutines.c
+++ b/misc/examples/coroutines.c
@@ -100,7 +100,7 @@ int main(void)
{
struct combined c = {.prm={.count=8}, .fib={14}};
- cco_run_blocked(&c, combined(&c)) {
+ cco_run(&c, combined(&c)) {
printf("Prime(%d)=%lld, Fib(%d)=%lld\n",
c.prm.idx, c.prm.result,
c.fib.idx, c.fib.result);
diff --git a/misc/examples/scheduler.c b/misc/examples/scheduler.c
index 04107d5e..bad5201b 100644
--- a/misc/examples/scheduler.c
+++ b/misc/examples/scheduler.c
@@ -25,7 +25,7 @@ static bool schedule(Scheduler* sched)
return !Scheduler_empty(sched);
}
-static bool resume_task(const struct Task* task)
+static bool push_task(const struct Task* task)
{
Scheduler_push_back(task->sched, *task);
return false;
@@ -36,11 +36,11 @@ static bool taskA(struct Task* task)
{
cco_begin(task);
puts("Hello, from task A");
- cco_yield(resume_task(task));
+ cco_yield(push_task(task));
puts("A is back doing work");
- cco_yield(resume_task(task));
+ cco_yield(push_task(task));
puts("A is back doing more work");
- cco_yield(resume_task(task));
+ cco_yield(push_task(task));
puts("A is back doing even more work");
cco_end(true);
}
@@ -49,9 +49,9 @@ static bool taskB(struct Task* task)
{
cco_begin(task);
puts("Hello, from task B");
- cco_yield(resume_task(task));
+ cco_yield(push_task(task));
puts("B is back doing work");
- cco_yield(resume_task(task));
+ cco_yield(push_task(task));
puts("B is back doing more work");
cco_end(true);
}