2009-11-15 20:38:24 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Andreas.Fink (Andreas.Fink85@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef TIMER_H
|
|
|
|
#define TIMER_H
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2009-12-27 20:33:02 +00:00
|
|
|
extern GSList* timeout_list;
|
|
|
|
extern struct timespec next_timeout;
|
2009-11-15 20:38:24 +00:00
|
|
|
|
|
|
|
|
2009-12-27 20:33:02 +00:00
|
|
|
struct timeout {
|
|
|
|
int interval_msec;
|
|
|
|
struct timespec timeout_expires;
|
2009-11-15 20:38:24 +00:00
|
|
|
void (*_callback)();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// timer functions
|
2009-12-27 20:33:02 +00:00
|
|
|
/** installs a timeout with the first timeout of 'value_msec' and then a periodic timeout with
|
|
|
|
* 'interval_msec'. '_callback' is the callback function when the timer reaches the timeout.
|
|
|
|
* returns a pointer to the timeout, which is needed for stopping it again **/
|
|
|
|
const struct timeout* add_timeout(int value_msec, int interval_msec, void (*_callback)());
|
|
|
|
|
|
|
|
void change_timeout(const struct timeout* t, int value_msec, int interval_msec, void (*_callback)());
|
|
|
|
|
|
|
|
/** stops the timeout 't' **/
|
|
|
|
void stop_timeout(const struct timeout* t);
|
|
|
|
|
|
|
|
/** stops all timeouts **/
|
|
|
|
void stop_all_timeouts();
|
|
|
|
|
|
|
|
void update_next_timeout();
|
|
|
|
void callback_timeout_expired();
|
2009-12-22 13:37:13 +00:00
|
|
|
|
2009-11-15 20:38:24 +00:00
|
|
|
#endif // TIMER_H
|