WWW-www.enlightenment.org pushed a commit to branch master.


commit 5d42cdf294d6905ba122ad65dffa859110dc938d
Author: Raster <ras...@rasterman.com>
Date:   Tue Apr 28 05:00:05 2015 -0700

    Wiki page ecore_idlers changed with summary [created] by Raster
 pages/docs/efl/ecore_idlers.txt | 49 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/pages/docs/efl/ecore_idlers.txt b/pages/docs/efl/ecore_idlers.txt
new file mode 100644
index 0000000..31b4bd2
--- /dev/null
+++ b/pages/docs/efl/ecore_idlers.txt
@@ -0,0 +1,49 @@
+~~Title: Idlers~~
+=== Idlers ===
+When your application is sleeping and waiting on something to wake it up, it 
is in the //Idle// state. It will normally sit here and consume no CPU cycles 
(in the [[mainloop]] during this time, waiting to wake up). There is an option 
to set up functions to run in a tight loop during this time, instead of 
sleeping. These are known as //Idlers//
+Idlers are rarely needed, and if you find yourself using them, be careful. If 
you do things like change the state of a canvas (widgets, other UI objects), 
such changes will not be automatically updated because the [[mainloop]] doesn't 
even know it should wake up and begin its usual processing, at the end of which 
before going idle again, it will begin UI updates. If you find yourself needing 
to do this, you will need to wake up the main loop. You could do this in 
various ways, by adding  [...]
+Every Idler registered will be called, one after the other, and when each 
idler callback returns, the [[mainloop]] will check if it should wake up from 
the idle state and process as normal, so keep your idler callbacks as short as 
possible to ensure the latency for a wake-up event is as low as possible.
+You add an idler with ecore_idler_add() which will return a handle to the 
idler object and take a callback with data pointer to pass to it as parameters. 
The return value of the function determines if it is deleted or not. If you 
return EINA_FALSE, then the idler will be deleted automatically for you, 
otherwise returning EINA_TRUE means it will keep being called until it is 
deleted with ecore_idler_del(). As follows:
+<code c>
+Ecore_Idler *my_idler;
+double start_time = 0.0;
+static Eina_Bool
+on_idle(void *data)
+   const char *string = data;
+   printf("String passed in is '%s'\n", string);
+   if ((ecore_time_get() - start_time) > 0.5)
+     {
+        my_idler = NULL;
+        return EINA_FALSE;
+     }
+   return EINA_TRUE;
+static void
+   static const char *string = "Hello World";
+   start_time = ecore_time_get();
+   my_idler = ecore_idler_add(on_idle, string);
+   if ((rand() % 4) == 0)
+     {
+        ecore_idler_del(my_idler);
+        my_idler = NULL;
+     }
+Note that the first (and only) parameter to the callback function is the 
''data'' parameter which can be a pointer to anything at all. Exactly this 
pointer is passed to your callback every time it is called. If this no longer 
points to valid data, it is your job to ensure it is not used or the idler is 
no longer called before that happens. Pointers are simply numbers with an 
address in memory (for all intents and purposes) and so thus imagine your 
pointer first says "Fred is at 213 Jones [...]
\ No newline at end of file


Reply via email to