1 | /* Copyright (c) 2014 Monty Program Ab |
2 | |
3 | This program is free software; you can redistribute it and/or modify |
4 | it under the terms of the GNU General Public License as published by |
5 | the Free Software Foundation; version 2 or later of the License. |
6 | |
7 | This program is distributed in the hope that it will be useful, |
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | GNU General Public License for more details. |
11 | |
12 | You should have received a copy of the GNU General Public License |
13 | along with this program; if not, write to the Free Software |
14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
15 | |
16 | /* Prototypes when using thr_timer functions */ |
17 | |
18 | #ifndef THR_TIMER_INCLUDED |
19 | #define THR_TIMER_INCLUDED |
20 | #ifdef __cplusplus |
21 | extern "C" { |
22 | #endif |
23 | |
24 | typedef struct st_timer { |
25 | struct timespec expire_time; |
26 | my_bool expired; |
27 | uint index_in_queue; |
28 | void (*func)(void*); |
29 | void *func_arg; |
30 | } thr_timer_t; |
31 | |
32 | /* Main functions for library */ |
33 | my_bool init_thr_timer(uint init_size_for_timer_queue); |
34 | void end_thr_timer(); |
35 | |
36 | /* Functions for handling one timer */ |
37 | void thr_timer_init(thr_timer_t *timer_data, void(*function)(void*), |
38 | void *arg); |
39 | my_bool thr_timer_settime(thr_timer_t *timer_data, ulonglong microseconds); |
40 | void thr_timer_end(thr_timer_t *timer_data); |
41 | |
42 | #ifdef __cplusplus |
43 | } |
44 | #endif /* __cplusplus */ |
45 | #endif /* THR_TIMER_INCLUDED */ |
46 | |