blob: b399fb17bafbec8143d33706695c010b613b1997 [file] [log] [blame]
James Kuszmaul82f6c042021-01-17 11:30:16 -08001/**
2 * @file re_tmr.h Interface to timer implementation
3 *
4 * Copyright (C) 2010 Creytiv.com
5 */
6
7
8/**
9 * Defines the timeout handler
10 *
11 * @param arg Handler argument
12 */
13typedef void (tmr_h)(void *arg);
14
15/** Defines a timer */
16struct tmr {
17 struct le le; /**< Linked list element */
18 tmr_h *th; /**< Timeout handler */
19 void *arg; /**< Handler argument */
20 uint64_t jfs; /**< Jiffies for timeout */
21};
22
23
24void tmr_poll(struct list *tmrl);
25uint64_t tmr_jiffies(void);
26uint64_t tmr_next_timeout(struct list *tmrl);
27void tmr_debug(void);
28int tmr_status(struct re_printf *pf, void *unused);
29
30void tmr_init(struct tmr *tmr);
31void tmr_start(struct tmr *tmr, uint64_t delay, tmr_h *th, void *arg);
32void tmr_cancel(struct tmr *tmr);
33uint64_t tmr_get_expire(const struct tmr *tmr);
34
35
36/**
37 * Check if the timer is running
38 *
39 * @param tmr Timer to check
40 *
41 * @return true if running, false if not running
42 */
43static inline bool tmr_isrunning(const struct tmr *tmr)
44{
45 return tmr ? NULL != tmr->th : false;
46}