summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/scheduler.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-05-24 16:21:22 +0200
committerTyge Løvset <[email protected]>2023-05-24 16:21:22 +0200
commit276b8110033aa275f58ce60d096f220ca050738c (patch)
tree76f5e2c069ecbe268c5497fafafb3b4cb7e66a51 /misc/examples/scheduler.c
parent8a19b4d6ff098ec014244c86569a7bea2db65514 (diff)
downloadSTC-modified-276b8110033aa275f58ce60d096f220ca050738c.tar.gz
STC-modified-276b8110033aa275f58ce60d096f220ca050738c.zip
coroutine.h:
- Renamed Liigo's coroutine macro cco(x) => cco_routine(x). - Removed cco_begin(x), cco_end() macros. Replaced by cco_routine(x). - Replaced csleep_ms() with csleep_us(), using select() which is portable. - Updated all coroutine examples.
Diffstat (limited to 'misc/examples/scheduler.c')
-rw-r--r--misc/examples/scheduler.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/misc/examples/scheduler.c b/misc/examples/scheduler.c
index 14c85f56..ea1414c7 100644
--- a/misc/examples/scheduler.c
+++ b/misc/examples/scheduler.c
@@ -34,7 +34,7 @@ static bool push_task(const struct Task* task)
static bool taskA(struct Task* task)
{
- cco_begin(task);
+ cco_routine(task) {
puts("Hello, from task A");
cco_yield(push_task(task));
puts("A is back doing work");
@@ -42,18 +42,20 @@ static bool taskA(struct Task* task)
puts("A is back doing more work");
cco_yield(push_task(task));
puts("A is back doing even more work");
- cco_end(true);
+ }
+ return true;
}
static bool taskB(struct Task* task)
{
- cco_begin(task);
+ cco_routine(task) {
puts("Hello, from task B");
cco_yield(push_task(task));
puts("B is back doing work");
cco_yield(push_task(task));
puts("B is back doing more work");
- cco_end(true);
+ }
+ return true;
}
void Use(void)