summaryrefslogtreecommitdiff
path: root/libddekit/include/ddekit/timer.h
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2012-02-19 06:14:24 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-02-19 06:14:24 +0000
commit6fafeb146e9efd59140ea58cebd7dd38ae9a6379 (patch)
tree7db89ba6a28932514b105d620bba4884ec332ec3 /libddekit/include/ddekit/timer.h
parent38c2c2458e3f4ecb329ff35621806252aac209b9 (diff)
parent8df772b3c665e663f6f9d2a70f9c691590bd3f91 (diff)
Merge branch 'dde' into upstream-merged
Diffstat (limited to 'libddekit/include/ddekit/timer.h')
-rw-r--r--libddekit/include/ddekit/timer.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/libddekit/include/ddekit/timer.h b/libddekit/include/ddekit/timer.h
new file mode 100644
index 00000000..387f2078
--- /dev/null
+++ b/libddekit/include/ddekit/timer.h
@@ -0,0 +1,59 @@
+#ifndef _ddekit_timer_h
+#define _ddekit_timer_h
+
+#include "ddekit/thread.h"
+
+#define jiffies (fetch_jiffies())
+#define HZ 100
+
+enum
+{
+ DDEKIT_INVALID_TIMER_ID = -1,
+};
+
+/** \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
+ */
+int ddekit_add_timer(void (*fn)(void *), void *args, unsigned long timeout);
+
+/** Delete timer with the corresponding timer id.
+ *
+ * \ingroup DDEKit_timer
+ */
+int ddekit_del_timer(int timer);
+
+/** Check whether a timer is pending
+ *
+ * \ingroup DDEKit_timer
+ *
+ * Linux needs this.
+ */
+int ddekit_timer_pending(int timer);
+
+/** Initialization function, startup timer thread
+ *
+ * \ingroup DDEKit_timer
+ */
+void ddekit_init_timers(void);
+
+/** Get the timer thread.
+ */
+ddekit_thread_t *ddekit_get_timer_thread(void);
+extern unsigned long fetch_jiffies (void);
+
+#endif