Javascript binding API - Ecore Idler

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.

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.

Functions

add(callback)

Syntax

function mycallback() { ... };
var idler = efl.Ecore.Idle.add(mycallback);

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.

Idlers are useful for progressively processing data without blocking.

addEnterer(callback)

Syntax

function mycallback() { ... };
var idler = efl.Ecore.Idle.addEnterer(mycallback);

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.

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.

addEntererBefore(callback)

Syntax

function mycallback() { ... };
var idler = efl.Ecore.Idle.addEntererBefore(mycallback);

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.

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.

addExiter(callback)

Syntax

function mycallback() { ... };
var idler = efl.Ecore.Idle.addExiter(mycallback);

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.

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.

idlerObj.del()

Syntax

idlerObj.del();

Deletes an idler from the list of active idlers.