WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=596507a3595e19e9a9c3b8986b750aad6f938266
commit 596507a3595e19e9a9c3b8986b750aad6f938266 Author: Lauro Moura <[email protected]> Date: Thu Dec 10 18:53:48 2015 -0800 Wiki page idle changed with summary [] by Lauro Moura --- pages/api/javascript/ecore/idle.txt | 39 +++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/pages/api/javascript/ecore/idle.txt b/pages/api/javascript/ecore/idle.txt index cea364a..be1df11 100644 --- a/pages/api/javascript/ecore/idle.txt +++ b/pages/api/javascript/ecore/idle.txt @@ -4,33 +4,54 @@ **DRAFT** -==== Constants ==== +The idler functionality in Ecore allows for callbacks to be called when the program isn't handling events, timers or fd handlers. +There are three types of idlers: Enterers, Idlers(proper) and Exiters. They are called, respectively, when the program is about to enter an idle state, when the program is in an idle state and when the program has just left an idle state and will begin processing events, timers or fd handlers. + +Enterer callbacks are good for updating your program's state if it has a state engine. Once all of the enterer handlers are called, the program will enter a "sleeping" state. + +Idler callbacks are called when the main loop has called all enterer handlers. They are useful for interfaces that require polling and timers would be too slow to use. + +Exiter callbacks are called when the main loop wakes up from an idle state. + +If no idler callbacks are specified, then the process literally goes to sleep. Otherwise, the idler callbacks are called continuously while the loop is "idle", using as much CPU as is available to the process. + +<note important> +The idle state doesn't mean that the **program** is idle, but that the **main loop** is idle. It doesn't have any timers, events, fd handlers or anything else to process (which in most event-driven programs also means that the **program** is idle too, but it's not a rule). The program itself may be doing a lot of processing in the idler, or in another thread, for example. +</note> ==== Functions ==== -=== add(args) === +=== add(callback) === Syntax <code javascript> - code +function mycallback() { ... }; +var idler = efl.Ecore.Idle.add(mycallback); </code> Parameters - * parameters + * callback - A function receiving no arguments to be called when the idler is activated. Return value - * return + * object - An object wrapping the newly created idler. + +Add an idler handle to the event loop, returning a handle on success and NULL otherwise. The function ''callback'' will be called repeatedly while no other events are ready to be processed, as long as it returns 1 (or ''efl.Ecore.Mainloop.CALLBACK_RENEW''). A return of 0 (or ''efl.Ecore.Mainloop.CALLBACK_CANCEL'') deletes the idler. + +<note tip> +Idlers are useful for progressively proccessing data without blocking. +</note> === addEnterer(args) === Syntax <code javascript> - code +function mycallback() { ... }; +var idler = efl.Ecore.Idle.addEnterer(mycallback); </code> Parameters @@ -46,7 +67,8 @@ Return value Syntax <code javascript> - code +function mycallback() { ... }; +var idler = efl.Ecore.Idle.addEntererBefore(mycallback); </code> Parameters @@ -62,7 +84,8 @@ Return value Syntax <code javascript> - code +function mycallback() { ... }; +var idler = efl.Ecore.Idle.addExiter(mycallback); </code> Parameters --
