00001 /* 00002 * $Id: timer.h 4871 2008-09-09 15:13:08Z henningw $ 00003 * 00004 * timer related functions 00005 * 00006 * Copyright (C) 2001-2003 FhG Fokus 00007 * Copyright (C) 2007 Voice Sistem SRL 00008 * 00009 * This file is part of Kamailio, a free SIP server. 00010 * 00011 * Kamailio is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version 00015 * 00016 * Kamailio is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 * 00025 * History: 00026 * -------- 00027 * 2007-02-02 timer with resolution of microseconds added (bogdan) 00028 */ 00029 00030 00031 /*! 00032 * \file 00033 * \brief Timer related functions 00034 */ 00035 00036 00037 #ifndef timer_h 00038 #define timer_h 00039 00040 /*! internal time representation */ 00041 typedef unsigned long long utime_t; 00042 00043 /*! timer function */ 00044 typedef void (timer_function)(unsigned int ticks, void* param); 00045 /*! timer function for utimers */ 00046 typedef void (utimer_function)(utime_t uticks, void* param); 00047 00048 00049 /*! timer list structure */ 00050 struct sr_timer{ 00051 int id; 00052 union { 00053 timer_function* timer_f; 00054 utimer_function* utimer_f; 00055 }u; 00056 void* t_param; 00057 unsigned int interval; 00058 00059 utime_t expires; 00060 00061 struct sr_timer* next; 00062 }; 00063 00064 #define TIMER_PROC_INIT_FLAG (1<<0) 00065 00066 00067 00068 int init_timer(void); 00069 00070 void destroy_timer(void); 00071 00072 int count_timer_procs(void); 00073 00074 int start_timer_processes(void); 00075 00076 int register_timer(timer_function f, void* param, unsigned int interval); 00077 00078 int register_utimer(utimer_function f, void* param, unsigned int interval); 00079 00080 int register_timer_process(timer_function f,void* param,unsigned int interval, 00081 unsigned int flags); 00082 00083 unsigned int get_ticks(void); 00084 00085 utime_t get_uticks(void); 00086 00087 #endif
1.5.6