On Thu, Nov 13, 2008 at 10:10 AM, Iván Briano (Sachiel)
<[EMAIL PROTECTED]> wrote:
> On Thu, Nov 13, 2008 at 9:22 AM, Gustavo Sverzut Barbieri
> <[EMAIL PROTECTED]> wrote:
>> Hi guys,
>>
>> Attached is a patch to add configurable precision for ecore timers, an
>> idea that I got at ELC-E from various power saving talks and also
>> after looking at my machine's powertop results with some effects
>> running.
>>
>> Since timers can be delayed by the system itself, for example under
>> heavy load, the idea here is to dispatch as much as possible the
>> timers at the same time. If we have timers that abs(t1 - t2) <=
>> precision, then have the timer to expire in max(t1, t2) and then
>> min(t1, t2) will be delayed up to precision amount. Maybe i was not
>> too clear, attached is also a test case.
>>
>> I still don't have any code using it, but possible I'll add to some products.
>>
>> Please comment and I'll commit it to SVN this weekend.
>>
>
> Only the test made it, it almost looks as if you've screwed up your mime
> types.
>
>> --
>> Gustavo Sverzut Barbieri
>> http://profusion.mobi embedded systems
>> --------------------------------------
>> MSN: [EMAIL PROTECTED]
>> Skype: gsbarbieri
>> Mobile: +55 (19) 9225-2202
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> enlightenment-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>>
>>
>
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [EMAIL PROTECTED]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
Index: src/lib/ecore/Ecore.h
===================================================================
--- src/lib/ecore/Ecore.h (revision 37472)
+++ src/lib/ecore/Ecore.h (working copy)
@@ -302,6 +302,9 @@
EAPI void ecore_timer_delay(Ecore_Timer *timer, double add);
EAPI double ecore_timer_pending_get(Ecore_Timer *timer);
+ EAPI double ecore_timer_precision_get(void);
+ EAPI void ecore_timer_precision_set(double precision);
+
EAPI Ecore_Animator *ecore_animator_add(int (*func) (void *data), const void *data);
EAPI void *ecore_animator_del(Ecore_Animator *animator);
EAPI void ecore_animator_frametime_set(double frametime);
Index: src/lib/ecore/ecore_private.h
===================================================================
--- src/lib/ecore/ecore_private.h (revision 37472)
+++ src/lib/ecore/ecore_private.h (working copy)
@@ -385,19 +385,19 @@
{
Ecore_List2 __list_data;
ECORE_MAGIC;
- signed char delete_me : 1;
- int (*func) (void *data);
- void *data;
+ unsigned char delete_me : 1;
+ int (*func) (void *data);
+ void *data;
};
struct _Ecore_Poller
{
Ecore_List2 __list_data;
ECORE_MAGIC;
- int ibit;
- signed char delete_me : 1;
- int (*func) (void *data);
- void *data;
+ int ibit;
+ unsigned char delete_me : 1;
+ int (*func) (void *data);
+ void *data;
};
#endif
Index: src/lib/ecore/ecore_timer.c
===================================================================
--- src/lib/ecore/ecore_timer.c (revision 37472)
+++ src/lib/ecore/ecore_timer.c (working copy)
@@ -8,6 +8,7 @@
static Ecore_Timer *timers = NULL;
static Ecore_Timer *suspended = NULL;
static double last_check = 0.0;
+static double precision = 10.0 / 1000000.0;
/**
* @defgroup Ecore_Time_Group Ecore Time Functions
@@ -17,6 +18,52 @@
*/
/**
+ * Retrieves the current precision used by timer infrastructure.
+ *
+ * @see ecore_timer_precision_set()
+ */
+EAPI double
+ecore_timer_precision_get(void)
+{
+ return precision;
+}
+
+/**
+ * Sets the precision to be used by timer infrastructure.
+ *
+ * When system calculates time to expire the next timer we'll be able
+ * to delay the timer by the given amount so more timers will fit in
+ * the same dispatch, waking up the system less often and thus being
+ * able to save power.
+ *
+ * Be aware that kernel may delay delivery even further, these delays
+ * are always possible due other tasks having higher priorities or
+ * other scheduler policies.
+ *
+ * Example:
+ * We have 2 timers, one that expires in a 2.0s and another that
+ * expires in 2.1s, if precision is 0.1s, then the Ecore will request
+ * for the next expire to happen in 2.1s and not 2.0s and another one
+ * of 0.1 as it would before.
+ *
+ * @note Ecore is smart enough to see if there are timers in the
+ * precision range, if it does not, in our example if no second timer
+ * in (T + precision) existed, then it would use the minimum timeout.
+ *
+ * @param value allowed introduced timeout delay, in seconds.
+ */
+EAPI void
+ecore_timer_precision_set(double value)
+{
+ if (value < 0.0)
+ {
+ fprintf(stderr, "ERROR: precision %f less than zero, ignored\n", value);
+ return;
+ }
+ precision = value;
+}
+
+/**
* Creates a timer to call the given function in the given period of time.
* @param in The interval in seconds.
* @param func The given function. If @p func returns 1, the timer is
@@ -281,23 +328,51 @@
}
}
+static inline Ecore_Timer *
+_ecore_timer_first_get(void)
+{
+ Ecore_Timer *timer = (Ecore_Timer *)timers;
+
+ while ((timer) && ((timer->delete_me) || (timer->just_added)))
+ timer = (Ecore_Timer *)((Ecore_List2 *)timer)->next;
+
+ return timer;
+}
+
+static inline Ecore_Timer *
+_ecore_timer_after_get(Ecore_Timer *base)
+{
+ Ecore_Timer *timer = (Ecore_Timer *)((Ecore_List2 *)base)->next;
+ double maxtime = base->at + precision;
+
+ while ((timer) && ((timer->delete_me) || (timer->just_added)) && (timer->at <= maxtime))
+ timer = (Ecore_Timer *)((Ecore_List2 *)timer)->next;
+
+ if ((!timer) || (timer->at > maxtime))
+ return NULL;
+
+ return timer;
+}
+
double
_ecore_timer_next_get(void)
{
double now;
double in;
- Ecore_Timer *timer;
-
- if (!timers) return -1;
+ Ecore_Timer *first, *second;
+
+ first = _ecore_timer_first_get();
+ if (!first) return -1;
+
+ second = _ecore_timer_after_get(first);
+ if (second)
+ first = second;
+
now = ecore_loop_time_get();
- timer = (Ecore_Timer *)timers;
- while ((timer) && ((timer->delete_me) || (timer->just_added)))
- timer = (Ecore_Timer *)((Ecore_List2 *)timer)->next;
- if (!timer) return -1;
- in = timer->at - now;
+ in = first->at - now;
if (in < 0) in = 0;
return in;
-}
+}
int
_ecore_timer_call(double when)
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel