summaryrefslogtreecommitdiffhomepage
path: root/include/stc/coroutine.h
diff options
context:
space:
mode:
authortylov <[email protected]>2023-07-30 22:46:33 +0200
committertylov <[email protected]>2023-07-30 22:46:33 +0200
commite6003c0ecfd7e76803bac7d98feca814997e8a86 (patch)
treeb63ce2c6886af2a1e396f98566902e562e830bd8 /include/stc/coroutine.h
parentb7efd45f0b59511be7202ce0641283e8a8ff6028 (diff)
downloadSTC-modified-e6003c0ecfd7e76803bac7d98feca814997e8a86.tar.gz
STC-modified-e6003c0ecfd7e76803bac7d98feca814997e8a86.zip
Added cco_generator(Name, ...) macro to simplify defining the iterator struct. Updated example generator.c
Diffstat (limited to 'include/stc/coroutine.h')
-rw-r--r--include/stc/coroutine.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/stc/coroutine.h b/include/stc/coroutine.h
index 9f55dddf..7917878a 100644
--- a/include/stc/coroutine.h
+++ b/include/stc/coroutine.h
@@ -132,7 +132,19 @@ typedef enum {
(void)((co)->cco_state = 0)
/*
- * Tasks (optional)
+ * Generators
+ */
+
+#define cco_generator(Name, ...) \
+ typedef Name Name##_value; \
+ typedef struct { \
+ Name##_value* ref; \
+ int cco_state; \
+ __VA_ARGS__ \
+ } Name##_iter
+
+/*
+ * Tasks
*/
struct cco_runtime;