summaryrefslogtreecommitdiffhomepage
path: root/docs
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 /docs
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 'docs')
-rw-r--r--docs/ccommon_api.md11
1 files changed, 5 insertions, 6 deletions
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md
index 5f6c82ed..beaad7e9 100644
--- a/docs/ccommon_api.md
+++ b/docs/ccommon_api.md
@@ -321,7 +321,7 @@ struct triples {
};
bool triples(struct triples* i) { // coroutine
- cco_begin(i);
+ cco_routine(i) {
for (i->c = 5; i->n; ++i->c) {
for (i->a = 1; i->a < i->c; ++i->a) {
for (i->b = i->a + 1; i->b < i->c; ++i->b) {
@@ -332,9 +332,10 @@ bool triples(struct triples* i) { // coroutine
}
}
}
- cco_final: // tear down
+ cco_final:
puts("done");
- cco_end(true);
+ }
+ return true;
}
int gcd(int a, int b) { // greatest common denominator
@@ -374,9 +375,7 @@ To resume the coroutine from where it was suspended with *cco_yield()*, simply c
| | `cco_return` | Early return from the coroutine (no arg) |
| `bool` | `cco_suspended(co)` | Is coroutine in suspended state? |
| `bool` | `cco_done(co)` | Is coroutine done? |
-| | `cco_begin(co)` | Begin coroutine block |
-| | `cco_end()` | End coroutine block |
-| | `cco_end(ret)` | End coroutine block and return ret |
+| | `cco_routine(co) { ... }` | The coroutine closure |
| | `cco_yield()` | Yield/suspend execution |
| | `cco_yield(ret)` | Yield/suspend execution and return ret |
| | `cco_yield_coro(co, call)` | Yield at co call if it is suspended |