summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/stc/algo/coroutine.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h
index 2e992e55..c786eb51 100644
--- a/include/stc/algo/coroutine.h
+++ b/include/stc/algo/coroutine.h
@@ -65,6 +65,7 @@ enum {
};
#define cco_initial(co) ((co)->cco_state == 0)
+#define cco_active(co) ((co)->cco_state >= 0)
#define cco_suspended(co) ((co)->cco_state > 0)
#define cco_done(co) ((co)->cco_state == cco_state_done)
@@ -172,6 +173,11 @@ static inline void ctimer_start(ctimer* tm, long msec) {
tm->start = clock();
}
+static inline ctimer ctimer_with(long msec) {
+ ctimer tm = {msec*(CLOCKS_PER_SEC/1000), clock()};
+ return tm;
+}
+
static inline void ctimer_restart(ctimer* tm) {
tm->start = clock();
}