This patch add the possibility to delay a timer and to know the
pending time before the next wake up.
They should not affect any current code using the timer.
--
Cedric BAIL
From 2789a338fadec7061367790647ee2196fe5e5112 Mon Sep 17 00:00:00 2001
From: Cedric BAIL <[EMAIL PROTECTED]>
Date: Mon, 7 Apr 2008 13:32:26 +0200
Subject: [PATCH] Add ecore_timer_delay and ecore_timer_pending_get.
---
src/lib/ecore/ecore_timer.c | 56 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 55 insertions(+), 1 deletions(-)
diff --git a/src/lib/ecore/ecore_timer.c b/src/lib/ecore/ecore_timer.c
index 480e0a3..93fce30 100644
--- a/src/lib/ecore/ecore_timer.c
+++ b/src/lib/ecore/ecore_timer.c
@@ -97,7 +97,61 @@ ecore_timer_interval_set(Ecore_Timer *timer, double in)
}
/**
- *
+ * Add some delay for the next occurence of a timer.
+ * This doesn't affect the interval of a timer.
+ *
+ * @param timer The timer to change.
+ * @param add The dalay to add to the next iteration.
+ * @ingroup Ecore_Time_Group
+ */
+EAPI void
+ecore_timer_delay(Ecore_Timer *timer, double add)
+{
+ if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
+ {
+ ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
+ "ecore_timer_delay");
+ return;
+ }
+
+ if (timer->frozen)
+ {
+ timer->pending += add;
+ }
+ else
+ {
+ timers = _ecore_list2_remove(timers, timer);
+ _ecore_timer_set(timer, timer->at + add, timer->in, timer->func, timer->data);
+ }
+}
+
+/**
+ * Get the pending time regarding a timer.
+ *
+ * @param timer The timer to learn from.
+ * @ingroup Ecore_Time_Group
+ */
+EAPI double
+ecore_timer_pending_get(Ecore_Timer *timer)
+{
+ double now;
+
+ if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
+ {
+ ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
+ "ecore_timer_pending_get");
+ return 0;
+ }
+
+ now = ecore_time_get();
+
+ if (timer->frozen)
+ return timer->pending;
+ return timer->at - now;
+}
+
+/**
+ *
*
*/
EAPI void
--
1.5.4.GIT
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Register now and save $200. Hurry, offer ends at 11:59 p.m.,
Monday, April 7! Use priority code J8TLD2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel