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