diff options
| author | Tyge Løvset <[email protected]> | 2023-07-04 09:35:00 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-07-04 09:35:00 +0200 |
| commit | e63a3dd6545261f5236a3d7e1c2be6571871b689 (patch) | |
| tree | b36d1fdf142b79f2ca6706813bed47f6ea73c756 /include | |
| parent | 433e6fd36912d1c584fbf206f99a3a982b29e9dc (diff) | |
| download | STC-modified-e63a3dd6545261f5236a3d7e1c2be6571871b689.tar.gz STC-modified-e63a3dd6545261f5236a3d7e1c2be6571871b689.zip | |
Removed cco_switch; won't work without state.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/algo/coroutine.h | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h index 198b0439..3a5382f3 100644 --- a/include/stc/algo/coroutine.h +++ b/include/stc/algo/coroutine.h @@ -73,11 +73,6 @@ typedef enum { #define cco_suspended(co) ((co)->cco_state > 0) #define cco_done(co) ((co)->cco_state == CCO_STATE_DONE) -/* Emulate switch in coro: always use { } after cco_case(val) and cco_default. */ -#define cco_switch(x) for (long long _sw = (long long)(x), _b=0; !_b; _b=1) -#define cco_case(val) if (_b |= _sw == (val)) -#define cco_default - #define cco_routine(co) \ for (int *_state = &(co)->cco_state; *_state != CCO_STATE_DONE; *_state = CCO_STATE_DONE) \ _resume: switch (*_state) case 0: // thanks, @liigo! @@ -107,8 +102,8 @@ typedef enum { /* cco_block_on(): assumes coroutine returns a cco_result value (int) */ #define cco_block_on(...) c_MACRO_OVERLOAD(cco_block_on, __VA_ARGS__) -#define cco_block_on_1(corocall) while (corocall != CCO_DONE) -#define cco_block_on_2(corocall, res) while ((*(res) = (corocall)) != CCO_DONE) +#define cco_block_on_1(corocall) while ((corocall) != CCO_DONE) +#define cco_block_on_2(corocall, result) while ((*(result) = (corocall)) != CCO_DONE) #define cco_cleanup \ *_state = CCO_STATE_CLEANUP; case CCO_STATE_CLEANUP |
