forked from enlightenment/www-content
Wiki page idle changed with summary [Move Javascript docs to legacy API] by Andrew Williams
This commit is contained in:
parent
167b520dee
commit
55a6cd98be
|
@ -0,0 +1,125 @@
|
||||||
|
===== Javascript binding API - Ecore Idler =====
|
||||||
|
|
||||||
|
[[api:javascript:ecore|Back to the JS Ecore page]]
|
||||||
|
|
||||||
|
**DRAFT**
|
||||||
|
|
||||||
|
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(callback) ===
|
||||||
|
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
<code javascript>
|
||||||
|
function mycallback() { ... };
|
||||||
|
var idler = efl.Ecore.Idle.add(mycallback);
|
||||||
|
</code>
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
|
||||||
|
* callback - A function receiving no arguments to be called when the idler is activated.
|
||||||
|
|
||||||
|
Return value
|
||||||
|
|
||||||
|
* 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 processing data without blocking.
|
||||||
|
</note>
|
||||||
|
|
||||||
|
=== addEnterer(callback) ===
|
||||||
|
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
<code javascript>
|
||||||
|
function mycallback() { ... };
|
||||||
|
var idler = efl.Ecore.Idle.addEnterer(mycallback);
|
||||||
|
</code>
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
|
||||||
|
* callback - A function receiving no arguments to be called when the idler is activated.
|
||||||
|
|
||||||
|
Return value
|
||||||
|
|
||||||
|
* object - An object wrapping the newly created idler.
|
||||||
|
|
||||||
|
Add an idle enterer handler.
|
||||||
|
|
||||||
|
<note important>
|
||||||
|
The function func will be called every time the main loop is **entering idle state**, as long as it returns 1 (or ''efl.Ecore.Mainloop.CALLBACK_RENEW''). A return of 0 (or ''efl.Ecore.Mainloop.CALLBACK_CANCEL'') deletes the idle enterer.
|
||||||
|
</note>
|
||||||
|
|
||||||
|
=== addEntererBefore(callback) ===
|
||||||
|
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
<code javascript>
|
||||||
|
function mycallback() { ... };
|
||||||
|
var idler = efl.Ecore.Idle.addEntererBefore(mycallback);
|
||||||
|
</code>
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
|
||||||
|
* callback - A function receiving no arguments to be called when the idler is activated.
|
||||||
|
|
||||||
|
Return value
|
||||||
|
|
||||||
|
* object - An object wrapping the newly created idler.
|
||||||
|
|
||||||
|
Add an idle enterer handler at the start of the list so it gets called earlier than others.
|
||||||
|
|
||||||
|
<note important>
|
||||||
|
The function func will be called every time the main loop is **entering idle state**, as long as it returns 1 (or ''efl.Ecore.Mainloop.CALLBACK_RENEW''). A return of 0 (or ''efl.Ecore.Mainloop.CALLBACK_CANCEL'') deletes the idle enterer.
|
||||||
|
</note>
|
||||||
|
|
||||||
|
=== addExiter(callback) ===
|
||||||
|
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
<code javascript>
|
||||||
|
function mycallback() { ... };
|
||||||
|
var idler = efl.Ecore.Idle.addExiter(mycallback);
|
||||||
|
</code>
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
|
||||||
|
* callback - A function receiving no arguments to be called when the idler is activated.
|
||||||
|
|
||||||
|
Return value
|
||||||
|
|
||||||
|
* object - An object wrapping the newly created idler.
|
||||||
|
|
||||||
|
Add an idle exiter handler.
|
||||||
|
|
||||||
|
<note important>
|
||||||
|
The function func will be called every time the main loop is **exiting idle state**, as long as it returns 1 (or ''efl.Ecore.Mainloop.CALLBACK_RENEW''). A return of 0 (or ''efl.Ecore.Mainloop.CALLBACK_CANCEL'') deletes the idle exiter.
|
||||||
|
</note>
|
||||||
|
|
||||||
|
=== idlerObj.del() ===
|
||||||
|
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
<code javascript>
|
||||||
|
idlerObj.del();
|
||||||
|
</code>
|
||||||
|
|
||||||
|
Deletes an idler from the list of active idlers.
|
Loading…
Reference in New Issue