]> Dogcows Code - chaz/tint2/blob - src/util/timer.h
df06fc3453ce7e3b879d2e16debd795bf71786c2
[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 struct timeout {
29 int interval_msec;
30 struct timespec timeout_expires;
31 void (*_callback)(void*);
32 void* arg;
33 void* multi_timeout;
34 };
35
36
37 // timer functions
38 /** installs a timeout with the first timeout of 'value_msec' and then a periodic timeout with
39 * 'interval_msec'. '_callback' is the callback function when the timer reaches the timeout.
40 * returns a pointer to the timeout, which is needed for stopping it again **/
41 const struct timeout* add_timeout(int value_msec, int interval_msec, void (*_callback)(void*), void* arg);
42
43 void change_timeout(const struct timeout* t, int value_msec, int interval_msec, void (*_callback)(void*), void* arg);
44
45 /** stops the timeout 't' **/
46 void stop_timeout(const struct timeout* t);
47
48 /** stops all timeouts **/
49 void stop_all_timeouts();
50
51 void update_next_timeout();
52 void callback_timeout_expired();
53
54 #endif // TIMER_H
This page took 0.035812 seconds and 3 git commands to generate.