2011-02-25 13:31:20 +01:00
|
|
|
#ifndef _DDEKIT_TIMER_H
|
|
|
|
#define _DDEKIT_TIMER_H
|
|
|
|
|
|
|
|
#include <ddekit/ddekit.h>
|
|
|
|
#include <ddekit/thread.h>
|
|
|
|
|
|
|
|
/** \defgroup DDEKit_timer
|
|
|
|
*
|
|
|
|
* Timer subsystem
|
|
|
|
*
|
|
|
|
* DDEKit provides a generic timer implementation that enables users
|
|
|
|
* to execute a function with some arguments after a certain period
|
|
|
|
* of time. DDEKit therefore starts a timer thread that executes these
|
|
|
|
* functions and keeps track of the currently running timers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Add a timer event. After the absolute timeout has expired, function fn
|
|
|
|
* is called with args as arguments.
|
|
|
|
*
|
|
|
|
* \ingroup DDEKit_timer
|
|
|
|
*
|
|
|
|
* \return >=0 valid timer ID
|
|
|
|
* \return < 0 error
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
int ddekit_add_timer(void (*fn)(void *), void *args, unsigned long
|
|
|
|
timeout);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/** Delete timer with the corresponding timer id.
|
|
|
|
*
|
|
|
|
* \ingroup DDEKit_timer
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
int ddekit_del_timer(int timer);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/** Check whether a timer is pending
|
|
|
|
*
|
|
|
|
* \ingroup DDEKit_timer
|
|
|
|
*
|
|
|
|
* Linux needs this.
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
int ddekit_timer_pending(int timer);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/** Initialization function, startup timer thread
|
|
|
|
*
|
|
|
|
* \ingroup DDEKit_timer
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
void ddekit_init_timers(void);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/** Get the timer thread.
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
ddekit_thread_t *ddekit_get_timer_thread(void);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
#endif
|