]> Dogcows Code - chaz/tint2/blob - src/util/timer.h
moved initial values in function default_xxx
[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* timeout_list;
25 extern struct timeval next_timeout;
26
27
28 typedef struct _timeout timeout;
29
30
31 // timer functions
32 /**
33 * Single shot timer (i.e. timer with interval_msec == 0) are deleted automatically as soon as they expire
34 * i.e. you do not need to stop them, however it is safe to call stop_timeout for these timers.
35 * Periodic timeouts are aligned to each other whenever possible, i.e. one interval_msec is an
36 * integral multiple of the other.
37 **/
38
39 /** default values **/
40 void default_timeout();
41 /** freed memory : stops all timeouts **/
42 void cleanup_timeout();
43
44 /** installs a timeout with the first timeout of 'value_msec' and then a periodic timeout with
45 * 'interval_msec'. '_callback' is the callback function when the timer reaches the timeout.
46 * returns a pointer to the timeout, which is needed for stopping it again
47 **/
48 timeout* add_timeout(int value_msec, int interval_msec, void (*_callback)(void*), void* arg);
49
50 /** changes timeout 't'. If timeout 't' does not exist, nothing happens **/
51 void change_timeout(timeout* t, int value_msec, int interval_msec, void (*_callback)(void*), void* arg);
52
53 /** stops the timeout 't' **/
54 void stop_timeout(timeout* t);
55
56 /** update_next_timeout updates next_timeout to the value, when the next installed timeout will expire **/
57 void update_next_timeout();
58
59 /** Callback of all expired timeouts **/
60 void callback_timeout_expired();
61
62 #endif // TIMER_H
This page took 0.03538 seconds and 4 git commands to generate.