From f8a47de5ec444c452093371e3db16857eb39a490 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 16 Mar 2003 21:11:39 +0000 Subject: merge the C branch into HEAD --- openbox/timer.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 openbox/timer.h (limited to 'openbox/timer.h') diff --git a/openbox/timer.h b/openbox/timer.h new file mode 100644 index 00000000..da6c8642 --- /dev/null +++ b/openbox/timer.h @@ -0,0 +1,38 @@ +#ifndef __timer_h +#define __timer_h + +#include + +/*! Data type of Timer callback */ +typedef void (*TimeoutHandler)(void *data); + +typedef struct Timer { + /*! Milliseconds between timer firings */ + long delay; + /*! Callback for timer expiry */ + TimeoutHandler action; + /*! Data sent to callback */ + void *data; + /*! We overload the delete operator to just set this to true */ + gboolean del_me; + /*! The time the last fire should've been at */ + GTimeVal last; + /*! When this timer will next trigger */ + GTimeVal timeout; +} Timer; + +/*! Initializes the timer subsection */ +void timer_startup(); +/*! Destroys the timer subsection */ +void timer_shutdown(); + +/* Creates a new timer with a given delay */ +Timer *timer_start(long delay, TimeoutHandler cb, void *data); +/* Stops and frees a timer */ +void timer_stop(Timer *self); + +/*! Dispatch all pending timers. Sets wait to the amount of time to wait for + the next timer, or NULL if there are no timers to wait for */ +void timer_dispatch(GTimeVal **wait); + +#endif -- cgit v1.2.3