1*433d6423SLionel Sambuc #ifndef _DDEKIT_TIMER_H 2*433d6423SLionel Sambuc #define _DDEKIT_TIMER_H 3*433d6423SLionel Sambuc 4*433d6423SLionel Sambuc #include <ddekit/ddekit.h> 5*433d6423SLionel Sambuc #include <ddekit/thread.h> 6*433d6423SLionel Sambuc 7*433d6423SLionel Sambuc /** \defgroup DDEKit_timer 8*433d6423SLionel Sambuc * 9*433d6423SLionel Sambuc * Timer subsystem 10*433d6423SLionel Sambuc * 11*433d6423SLionel Sambuc * DDEKit provides a generic timer implementation that enables users 12*433d6423SLionel Sambuc * to execute a function with some arguments after a certain period 13*433d6423SLionel Sambuc * of time. DDEKit therefore starts a timer thread that executes these 14*433d6423SLionel Sambuc * functions and keeps track of the currently running timers. 15*433d6423SLionel Sambuc */ 16*433d6423SLionel Sambuc 17*433d6423SLionel Sambuc /** Add a timer event. After the absolute timeout has expired, function fn 18*433d6423SLionel Sambuc * is called with args as arguments. 19*433d6423SLionel Sambuc * 20*433d6423SLionel Sambuc * \ingroup DDEKit_timer 21*433d6423SLionel Sambuc * 22*433d6423SLionel Sambuc * \return >=0 valid timer ID 23*433d6423SLionel Sambuc * \return < 0 error 24*433d6423SLionel Sambuc */ 25*433d6423SLionel Sambuc int ddekit_add_timer(void (*fn)(void *), void *args, unsigned long 26*433d6423SLionel Sambuc timeout); 27*433d6423SLionel Sambuc 28*433d6423SLionel Sambuc /** Delete timer with the corresponding timer id. 29*433d6423SLionel Sambuc * 30*433d6423SLionel Sambuc * \ingroup DDEKit_timer 31*433d6423SLionel Sambuc */ 32*433d6423SLionel Sambuc int ddekit_del_timer(int timer); 33*433d6423SLionel Sambuc 34*433d6423SLionel Sambuc /** Check whether a timer is pending 35*433d6423SLionel Sambuc * 36*433d6423SLionel Sambuc * \ingroup DDEKit_timer 37*433d6423SLionel Sambuc * 38*433d6423SLionel Sambuc * Linux needs this. 39*433d6423SLionel Sambuc */ 40*433d6423SLionel Sambuc int ddekit_timer_pending(int timer); 41*433d6423SLionel Sambuc 42*433d6423SLionel Sambuc /** Initialization function, startup timer thread 43*433d6423SLionel Sambuc * 44*433d6423SLionel Sambuc * \ingroup DDEKit_timer 45*433d6423SLionel Sambuc */ 46*433d6423SLionel Sambuc void ddekit_init_timers(void); 47*433d6423SLionel Sambuc 48*433d6423SLionel Sambuc /** Get the timer thread. 49*433d6423SLionel Sambuc */ 50*433d6423SLionel Sambuc ddekit_thread_t *ddekit_get_timer_thread(void); 51*433d6423SLionel Sambuc 52*433d6423SLionel Sambuc #endif 53