+
+INLINE void timer_poll(List *queue)
+{
+ Timer *timer;
+
+ /*
+ * Check the first timer request in the list and process
+ * it when it has expired. Repeat this check until the
+ * first node has not yet expired. Since the list is sorted
+ * by expiry time, all the following requests are guaranteed
+ * to expire later.
+ */
+ while ((timer = (Timer *)LIST_HEAD(queue))->link.succ)
+ {
+ /* This request in list has not yet expired? */
+ if (timer_clock() - timer->tick < 0)
+ break;
+
+ /* Retreat the expired timer */
+ REMOVE(&timer->link);
+ DB(timer->magic = TIMER_MAGIC_INACTIVE;)
+
+ /* Execute the associated event */
+ event_do(&timer->expire);
+ }
+}
+
+/**
+ * Add \a timer to \a queue.
+ * \see synctimer_poll() for details.
+ */
+void synctimer_add(Timer *timer, List *queue)
+{
+ timer_addToList(timer, queue);
+}
+
+/**
+ * Simple synchronous timer based scheduler polling routine.
+ *
+ * Sometimes you would like to have a proper scheduler,
+ * but you can't afford it due to memory constraints.
+ *
+ * This is a simple replacement: you can create events and call
+ * them periodically at specific time intervals.
+ * All you have to do is to set up normal timers, and call synctimer_add()
+ * instead of timer_add() to add the events to your specific queue.
+ * Then, in the main loop or wherever you want, you can call
+ * synctimer_poll() to process expired events. The associated callbacks will be
+ * executed.
+ * As this is done synchronously you don't have to worry about race conditions.
+ * You can kill an event by simply calling synctimer_abort().
+ *
+ */
+void synctimer_poll(List *queue)
+{
+ timer_poll(queue);
+}
+