From 8497b5497ecba2c2f1d368c9161ec52d4f03ae30 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 26 May 2023 19:36:27 +0200 Subject: Minor addition to coroutine API. --- include/stc/algo/coroutine.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') 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(); } -- cgit v1.2.3