libosmocore  0.9.3
Osmocom core library
timer.h
Go to the documentation of this file.
1 /*
2  * (C) 2008, 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
3  * All Rights Reserved
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  */
20 
29 #pragma once
30 
31 #include <sys/time.h>
32 
33 #include <osmocom/core/linuxlist.h>
34 #include <osmocom/core/linuxrbtree.h>
35 
54  struct rb_node node;
55  struct llist_head list;
56  struct timeval timeout;
57  unsigned int active : 1;
59  void (*cb)(void*);
60  void *data;
61 };
62 
67 void osmo_timer_add(struct osmo_timer_list *timer);
68 
69 void osmo_timer_schedule(struct osmo_timer_list *timer, int seconds, int microseconds);
70 
71 void osmo_timer_del(struct osmo_timer_list *timer);
72 
73 int osmo_timer_pending(struct osmo_timer_list *timer);
74 
75 int osmo_timer_remaining(const struct osmo_timer_list *timer,
76  const struct timeval *now,
77  struct timeval *remaining);
78 /*
79  * internal timer list management
80  */
81 struct timeval *osmo_timers_nearest(void);
82 void osmo_timers_prepare(void);
83 int osmo_timers_update(void);
84 int osmo_timers_check(void);
85