37 #ifndef LELY_UTIL_COROUTINE_H_ 38 #define LELY_UTIL_COROUTINE_H_ 46 #define CO_LABEL_TYPE int 64 #define co_restart(ctx) co_restart__(ctx) 65 #define co_restart__(ctx) ((void)((ctx)->label = 0)) 68 #define co_is_ready(ctx) co_is_ready__(ctx) 69 #define co_is_ready__(ctx) ((ctx)->label == -1) 110 #define co_reenter(ctx) co_reenter__(ctx) 111 #define co_reenter__(ctx) \ 112 for (CO_LABEL_TYPE *const _co_label_ = &(ctx)->label; \ 113 *_co_label_ != -1; *_co_label_ = -1) \ 115 goto _co_continue_; \ 123 switch (*_co_label_) \ 127 #define co_label__ (__COUNTER__ + 1) 129 #define co_label__ __LINE__ 143 #define co_yield co_yield__(co_label__) 145 #define co_yield__(label) \ 146 for (*_co_label_ = (label);;) \ 154 goto _co_continue_; \ 220 #define co_fork co_fork__(co_label__) 221 #define co_fork__(label) \ 222 for (*_co_label_ = -(label)-1;; *_co_label_ = (label)) \ 223 if (_co_label_ == (label)) { \ 224 case -(label)-1: break; \ 228 #define co_is_parent() (!co_is_child()) 231 #define co_is_child() (*_co_label_ < -1) 233 #endif // !LELY_UTIL_COROUTINE_H_ The type holding the context (i.e., program counter) of a stackless coroutine.
#define CO_LABEL_TYPE
The type used to store the label (i.e., program counter) of a stackless coroutine.