summaryrefslogtreecommitdiffhomepage
path: root/include/stc/algo
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-05-26 19:36:27 +0200
committerTyge Løvset <[email protected]>2023-05-26 19:36:27 +0200
commit8497b5497ecba2c2f1d368c9161ec52d4f03ae30 (patch)
tree86bd77ae8b1911a5db07b624089ba62b53dfa7cb /include/stc/algo
parent3f840ffe1c9d2df998e1cbcf6c87ea72fe23f97e (diff)
downloadSTC-modified-8497b5497ecba2c2f1d368c9161ec52d4f03ae30.tar.gz
STC-modified-8497b5497ecba2c2f1d368c9161ec52d4f03ae30.zip
Minor addition to coroutine API.
Diffstat (limited to 'include/stc/algo')
-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();
}