Macros | Typedefs
Ecore Idle functions

The idler functionality in Ecore allows for callbacks to be called when the program isn't handling events, timers or fd handlers. More...

Typedefs

typedef Eo Ecore_Idler
 A handle for idlers.
 
typedef Eo Ecore_Idle_Enterer
 A handle for idle enterers.
 
typedef Eo Ecore_Idle_Exiter
 A handle for idle exiters.
 
Ecore_Idlerecore_idler_add (Ecore_Task_Cb func, const void *data)
 Add an idler handler. More...
 
void * ecore_idler_del (Ecore_Idler *idler)
 Delete an idler callback from the list to be executed. More...
 
Ecore_Idle_Entererecore_idle_enterer_add (Ecore_Task_Cb func, const void *data)
 Add an idle enterer handler. More...
 
Ecore_Idle_Entererecore_idle_enterer_before_add (Ecore_Task_Cb func, const void *data)
 Add an idle enterer handler at the start of the list so it gets called earlier than others. More...
 
void * ecore_idle_enterer_del (Ecore_Idle_Enterer *idle_enterer)
 Delete an idle enterer callback. More...
 
Ecore_Idle_Exiterecore_idle_exiter_add (Ecore_Task_Cb func, const void *data)
 Add an idle exiter handler. More...
 
void * ecore_idle_exiter_del (Ecore_Idle_Exiter *idle_exiter)
 Delete an idle exiter handler from the list to be run on exiting idle state. More...
 

Detailed Description

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
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.

Example with functions that deal with idle state:

Function Documentation

Ecore_Idler* ecore_idler_add ( Ecore_Task_Cb  func,
const void *  data 
)

Add an idler handler.

Parameters
funcThe function to call when idling.
dataThe data to be passed to this func call.
Returns
A idler handle if successfully added, NULL otherwise.

Add an idler handle to the event loop, returning a handle on success and NULL otherwise. The function func will be called repeatedly while no other events are ready to be processed, as long as it returns 1 (or ECORE_CALLBACK_RENEW). A return of 0 (or ECORE_CALLBACK_CANCEL) deletes the idler.

Idlers are useful for progressively prossessing data without blocking.

References eina_inlist_append(), EINA_INLIST_GET, EINA_MAIN_LOOP_CHECK_RETURN, eina_main_loop_is(), EINA_TRUE, EINA_UNLIKELY, eo_add, eo_manual_free_set(), and ERR.

Referenced by ecore_wl_dnd_drag_types_get(), eldbus_name_owner_changed_callback_add(), eldbus_service_interface_fallback_register2(), eldbus_service_property_changed(), eldbus_shutdown(), ethumb_client_generate(), and ethumb_file_free().

void* ecore_idler_del ( Ecore_Idler idler)

Delete an idler callback from the list to be executed.

Parameters
idlerThe handle of the idler callback to delete
Returns
The data pointer passed to the idler callback on success, NULL otherwise.

References eina_evlog(), EINA_FALSE, EINA_INLIST_GET, eina_inlist_remove(), EINA_MAIN_LOOP_CHECK_RETURN_VAL, eo_data_scope_get(), eo_destructed_is(), eo_manual_free(), and eo_manual_free_set().

Referenced by eldbus_connection_ref(), eldbus_name_owner_changed_callback_del(), eldbus_service_interface_fallback_register2(), eldbus_service_object_manager_attach(), eldbus_shutdown(), ethumb_file_free(), and ethumb_free().

Ecore_Idle_Enterer* ecore_idle_enterer_add ( Ecore_Task_Cb  func,
const void *  data 
)

Add an idle enterer handler.

Parameters
funcThe function to call when entering an idle state.
dataThe data to be passed to the func call
Returns
A handle to the idle enterer callback if successful. Otherwise, NULL is returned.
Note
The function func will be called every time the main loop is entering idle state, as long as it returns 1 (or ECORE_CALLBACK_RENEW). A return of 0 (or ECORE_CALLBACK_CANCEL) deletes the idle enterer.
Examples:
ecore_idler_example.c.

References eina_inlist_append(), EINA_INLIST_GET, and eo_add.

Referenced by ecore_evas_init(), ecore_wl2_display_connect(), ecore_wl_init(), and ecore_x_init().

Ecore_Idle_Enterer* ecore_idle_enterer_before_add ( Ecore_Task_Cb  func,
const void *  data 
)

Add an idle enterer handler at the start of the list so it gets called earlier than others.

Parameters
funcThe function to call when entering an idle state.
dataThe data to be passed to the func call
Returns
A handle to the idle enterer callback if successful. Otherwise, NULL is returned.
Note
The function func will be called every time the main loop is entering idle state, as long as it returns 1 (or ECORE_CALLBACK_RENEW). A return of 0 (or ECORE_CALLBACK_CANCEL) deletes the idle enterer.

References EINA_INLIST_GET, eina_inlist_prepend(), and eo_add.

void* ecore_idle_enterer_del ( Ecore_Idle_Enterer idle_enterer)

Delete an idle enterer callback.

Parameters
idle_entererThe idle enterer to delete
Returns
The data pointer passed to the idler enterer callback on success. NULL otherwise.
Examples:
ecore_idler_example.c.

References eina_evlog(), EINA_FALSE, EINA_INLIST_GET, eina_inlist_remove(), EINA_MAIN_LOOP_CHECK_RETURN_VAL, eo_data_scope_get(), eo_destructed_is(), eo_manual_free(), and eo_manual_free_set().

Referenced by ecore_evas_shutdown(), ecore_wl_server_mode_set(), and ecore_x_double_click_time_get().

Ecore_Idle_Exiter* ecore_idle_exiter_add ( Ecore_Task_Cb  func,
const void *  data 
)

Add an idle exiter handler.

Parameters
funcThe function to call when exiting an idle state.
dataThe data to be passed to the func call
Returns
A handle to the idle exiter callback on success. NULL otherwise.
Note
The function func will be called every time the main loop is exiting idle state, as long as it returns 1 (or ECORE_CALLBACK_RENEW). A return of 0 (or ECORE_CALLBACK_CANCEL) deletes the idle exiter.
Examples:
ecore_idler_example.c.

References eina_inlist_append(), EINA_INLIST_GET, EINA_MAIN_LOOP_CHECK_RETURN, EINA_TRUE, eo_add, eo_manual_free_set(), and ERR.

void* ecore_idle_exiter_del ( Ecore_Idle_Exiter idle_exiter)

Delete an idle exiter handler from the list to be run on exiting idle state.

Parameters
idle_exiterThe idle exiter to delete
Returns
The data pointer that was being being passed to the handler if successful. NULL otherwise.
Examples:
ecore_idler_example.c.

References eina_evlog(), EINA_FALSE, EINA_INLIST_GET, eina_inlist_remove(), EINA_MAIN_LOOP_CHECK_RETURN_VAL, eo_data_scope_get(), eo_destructed_is(), eo_manual_free(), and eo_manual_free_set().