libosmocore
0.9.3
Osmocom core library
|
00001 /* 00002 * (C) 2008, 2009 by Holger Hans Peter Freyther <zecke@selfish.org> 00003 * All Rights Reserved 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 * 00019 */ 00020 00029 #pragma once 00030 00031 #include <sys/time.h> 00032 00033 #include <osmocom/core/linuxlist.h> 00034 #include <osmocom/core/linuxrbtree.h> 00035 00053 struct osmo_timer_list { 00054 struct rb_node node; 00055 struct llist_head list; 00056 struct timeval timeout; 00057 unsigned int active : 1; 00059 void (*cb)(void*); 00060 void *data; 00061 }; 00062 00067 void osmo_timer_add(struct osmo_timer_list *timer); 00068 00069 void osmo_timer_schedule(struct osmo_timer_list *timer, int seconds, int microseconds); 00070 00071 void osmo_timer_del(struct osmo_timer_list *timer); 00072 00073 int osmo_timer_pending(struct osmo_timer_list *timer); 00074 00075 int osmo_timer_remaining(const struct osmo_timer_list *timer, 00076 const struct timeval *now, 00077 struct timeval *remaining); 00078 /* 00079 * internal timer list management 00080 */ 00081 struct timeval *osmo_timers_nearest(void); 00082 void osmo_timers_prepare(void); 00083 int osmo_timers_update(void); 00084 int osmo_timers_check(void); 00085