]> Dogcows Code - chaz/tint2/blob - src/util/timer.h
fae0203546c39dd40e6847f8285d4c6435622b03
[chaz/tint2] / src / util / timer.h
1 /**************************************************************************
2 *
3 * Copyright (C) 2009 Andreas.Fink (Andreas.Fink85@gmail.com)
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 **************************************************************************/
17
18
19 #ifndef TIMER_H
20 #define TIMER_H
21
22 #include <glib.h>
23
24 extern GSList* timer_list;
25
26
27 struct timer {
28 int id;
29 void (*_callback)();
30 };
31
32
33 // timer functions
34 /** installs a timer with the first timeout 'value_sec' and then a periodic timeout with interval_sec
35 * '_callback' is the callback function when the timer reaches the timeout.
36 * If 'value_sec' == 0 then the timer is disabled (but not uninstalled)
37 * If 'interval_sec' == 0 the timer is a single shot timer, ie. no periodic timeout occur
38 * returns the 'id' of the timer, which is needed for uninstalling the timer **/
39 int install_timer(int value_sec, int value_nsec, int interval_sec, int interval_nsec, void (*_callback)());
40
41 /** resets a timer to the new values. If 'id' does not exist nothing happens.
42 * If value_sec == 0 the timer is stopped **/
43 void reset_timer(int id, int value_sec, int value_nsec, int interval_sec, int interval_nsec);
44
45 /** uninstalls a timer with the given 'id'. If no timer is installed with this id nothing happens **/
46 void uninstall_timer(int id);
47
48 #endif // TIMER_H
This page took 0.032651 seconds and 3 git commands to generate.