1 /**
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  */
13 typedef void (tmr_h)(void *arg);
14 
15 /** Defines a timer */
16 struct 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 
24 void     tmr_poll(struct list *tmrl);
25 uint64_t tmr_jiffies(void);
26 uint64_t tmr_next_timeout(struct list *tmrl);
27 void     tmr_debug(void);
28 int      tmr_status(struct re_printf *pf, void *unused);
29 
30 void     tmr_init(struct tmr *tmr);
31 void     tmr_start(struct tmr *tmr, uint64_t delay, tmr_h *th, void *arg);
32 void     tmr_cancel(struct tmr *tmr);
33 uint64_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  */
tmr_isrunning(const struct tmr * tmr)43 static inline bool tmr_isrunning(const struct tmr *tmr)
44 {
45 	return tmr ? NULL != tmr->th : false;
46 }
47