Ecore poller provides infrastructure for the creation of pollers. More...
Typedefs | |
typedef struct _Ecore_Poller | Ecore_Poller |
Enumerations | |
enum | Ecore_Poller_Type { ECORE_POLLER_CORE = 0 } |
Functions | |
Ecore_Poller * | ecore_poller_add (Ecore_Poller_Type type, int interval, Ecore_Task_Cb func, const void *data) |
Creates a poller to call the given function at a particular tick interval. More... | |
void * | ecore_poller_del (Ecore_Poller *poller) |
Deletes the specified poller from the timer list. More... | |
void | ecore_poller_poll_interval_set (Ecore_Poller_Type type, double poll_time) |
Sets the time(in seconds) between ticks for the given poller type. More... | |
double | ecore_poller_poll_interval_get (Ecore_Poller_Type type) |
Gets the time(in seconds) between ticks for the given poller type. More... | |
Eina_Bool | ecore_poller_poller_interval_set (Ecore_Poller *obj, int interval) |
Polling interval rate of the poller. More... | |
int | ecore_poller_poller_interval_get (const Ecore_Poller *obj) |
Polling interval rate of the poller. More... | |
Ecore poller provides infrastructure for the creation of pollers.
Pollers are, in essence, callbacks that share a single timer per type. Because not all pollers need to be called at the same frequency the user may specify the frequency in ticks(each expiration of the shared timer is called a tick, in ecore poller parlance) for each added poller. Ecore pollers should only be used when the poller doesn't have specific requirements on the exact times to poll.
This architecture means that the main loop is only woken up once to handle all pollers of that type, this will save power as the CPU has more of a chance to go into a low power state the longer it is asleep for, so this should be used in situations where power usage is a concern.
For now only 1 core poller type is supported: ECORE_POLLER_CORE, the default interval for ECORE_POLLER_CORE is 0.125(or 1/8th) second.
The creation of a poller is extremely simple and only requires one line:
This sample creates a poller to call my_poller_function
at every tick with NULL
as data.
Example:
enum Ecore_Poller_Type |
Ecore_Poller * ecore_poller_add | ( | Ecore_Poller_Type | type, |
int | interval, | ||
Ecore_Task_Cb | func, | ||
const void * | data | ||
) |
Creates a poller to call the given function at a particular tick interval.
type | The ticker type to attach the poller to. Must be ECORE_POLLER_CORE. |
interval | The poll interval. |
func | The poller function. |
data | Data to pass to func when it is called. |
NULL
otherwise.This function adds func as a poller callback that will be called every interval ticks together with other pollers of type type. func will be passed the data
pointer as a parameter.
The interval
must be between 1 and 32768 inclusive, and must be a power of 2 (i.e. 1, 2, 4, 8, 16, ... 16384, 32768). The exact tick in which func will be called is undefined, as only the interval between calls can be defined. Ecore will endeavor to keep pollers synchronized and to call as many in 1 wakeup event as possible. If interval is not a power of two, the closest power of 2 greater than interval will be used.
When the poller func
is called, it must return a value of either ECORE_CALLBACK_RENEW
(or 1
) or ECORE_CALLBACK_CANCEL
(or 0
). If it returns 1
, it will be called again at the next tick, or if it returns 0
it will be deleted automatically making any references/handles for it invalid.
References EINA_INLIST_GET, eina_inlist_prepend(), EINA_MAIN_LOOP_CHECK_RETURN_VAL, and ERR.
Referenced by ecore_init(), and elm_prefs_data_autosave_set().
void * ecore_poller_del | ( | Ecore_Poller * | poller | ) |
Deletes the specified poller from the timer list.
poller | The poller to delete. |
NULL
otherwise.0
, the handle is no longer valid (and does not need to be deleted). References EINA_MAIN_LOOP_CHECK_RETURN_VAL.
Referenced by elm_prefs_data_autosave_set(), and elm_prefs_data_save().
void ecore_poller_poll_interval_set | ( | Ecore_Poller_Type | type, |
double | poll_time | ||
) |
Sets the time(in seconds) between ticks for the given poller type.
type | The poller type to adjust. |
poll_time | The time(in seconds) between ticks of the timer. |
This will adjust the time between ticks of the given timer type defined by type
to the time period defined by poll_time
.
References EINA_MAIN_LOOP_CHECK_RETURN, and ERR.
double ecore_poller_poll_interval_get | ( | Ecore_Poller_Type | type | ) |
Gets the time(in seconds) between ticks for the given poller type.
type | The poller type to query. |
This will get the time between ticks of the specified poller timer.
References EINA_MAIN_LOOP_CHECK_RETURN_VAL.
Eina_Bool ecore_poller_poller_interval_set | ( | Ecore_Poller * | obj, |
int | interval | ||
) |
Polling interval rate of the poller.
[in] | interval | The tick interval; must be a power of 2 and <= 32768. |
true
on success, false
on failure. References EINA_FALSE, EINA_INLIST_GET, eina_inlist_prepend(), eina_inlist_remove(), EINA_MAIN_LOOP_CHECK_RETURN_VAL, and EINA_TRUE.
int ecore_poller_poller_interval_get | ( | const Ecore_Poller * | obj | ) |
Polling interval rate of the poller.
References EINA_MAIN_LOOP_CHECK_RETURN_VAL.