summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-05-01 23:11:45 +0200
committerTyge Løvset <[email protected]>2023-05-01 23:11:45 +0200
commit399eb8d0e1de2839d826a9e0cf123d90d00b0018 (patch)
treea8731f86aa779af8412ba77e4d27fa5e66b94cab /include
parentf916573e2b3652d9b3f6fb82aadd5f2cfb3ce2fe (diff)
downloadSTC-modified-399eb8d0e1de2839d826a9e0cf123d90d00b0018.tar.gz
STC-modified-399eb8d0e1de2839d826a9e0cf123d90d00b0018.zip
Replaced cco_yield(corocall, ctx, retval) with cco_await(cond) and cco_await_while(cond).
Diffstat (limited to 'include')
-rw-r--r--include/stc/algo/coroutine.h16
1 files changed, 6 insertions, 10 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h
index b0ecd6b7..6c1d7d28 100644
--- a/include/stc/algo/coroutine.h
+++ b/include/stc/algo/coroutine.h
@@ -64,6 +64,7 @@ enum {
#define cco_suspended(ctx) ((ctx)->cco_state > 0)
#define cco_alive(ctx) ((ctx)->cco_state != cco_state_done)
+#define cco_done(ctx) ((ctx)->cco_state == cco_state_done)
#define cco_begin(ctx) \
int *_state = &(ctx)->cco_state; \
@@ -76,25 +77,20 @@ enum {
} \
return retval
-#define cco_yield(...) c_MACRO_OVERLOAD(cco_yield, __VA_ARGS__)
-#define cco_yield_1(retval) \
+#define cco_yield(retval) \
do { \
*_state = __LINE__; return retval; \
case __LINE__:; \
} while (0)
-#define cco_yield_2(corocall2, ctx2) \
- cco_yield_3(corocall2, ctx2, )
-
-#define cco_yield_3(corocall2, ctx2, retval) \
+#define cco_await_while(cond, retval) \
do { \
*_state = __LINE__; \
- do { \
- corocall2; if (cco_suspended(ctx2)) return retval; \
- case __LINE__:; \
- } while (cco_alive(ctx2)); \
+ case __LINE__: if (cond) return retval; \
} while (0)
+#define cco_await(cond) cco_await_while(!(cond), true)
+
#define cco_final \
case cco_state_final: \
_cco_final_