Ecore provides very flexible timer functionality. More...
Typedefs | |
typedef Eo | Ecore_Timer |
A handle for timers. | |
Functions | |
double | ecore_timer_precision_get (void) |
Retrieves the current precision used by timer infrastructure. More... | |
void | ecore_timer_precision_set (double precision) |
Sets the precision to be used by timer infrastructure. More... | |
char * | ecore_timer_dump (void) |
This function returns a human readable text-based log for Ecore_Timer events. More... | |
Ecore_Timer * | ecore_timer_add (double in, Ecore_Task_Cb func, const void *data) |
Creates a timer to call the given function in the given period of time. More... | |
Ecore_Timer * | ecore_timer_loop_add (double in, Ecore_Task_Cb func, const void *data) |
Creates a timer to call the given function in the given period of time. More... | |
void * | ecore_timer_del (Ecore_Timer *timer) |
Deletes the specified timer from the timer list. More... | |
void | ecore_timer_freeze (Ecore_Timer *timer) |
Eina_Bool | ecore_timer_freeze_get (Ecore_Timer *timer) |
void | ecore_timer_thaw (Ecore_Timer *timer) |
Ecore provides very flexible timer functionality.
The basic usage of timers, to call a certain function at a certain interval can be achieved with a single line:
ECORE_CALLBACK_CANCEL
instead.An example that shows the usage of a lot of these:
double ecore_timer_precision_get | ( | void | ) |
Retrieves the current precision used by timer infrastructure.
References EINA_MAIN_LOOP_CHECK_RETURN_VAL.
void ecore_timer_precision_set | ( | double | precision | ) |
Sets the precision to be used by timer infrastructure.
precision | Allowed introduced timeout delay, in seconds. |
This sets the precision for all timers. The precision determines how much of an difference from the requested interval is acceptable. One common reason to use this function is to increase the allowed timeout and thus decrease precision of the timers, this is because less precise the timers result in the system waking up less often and thus consuming less resources.
Be aware that kernel may delay delivery even further, these delays are always possible due other tasks having higher priorities or other scheduler policies.
Example: We have 2 timers, one that expires in a 2.0s and another that expires in 2.1s, if precision is 0.1s, then the Ecore will request for the next expire to happen in 2.1s and not 2.0s and another one of 0.1 as it would before.
References _Efl_Callback_Array_Item_Full::desc, ecore_time_get(), EFL_CALLBACKS_ARRAY_DEFINE, efl_data_scope_get(), efl_del(), EFL_EVENT_CALLBACK_ADD, efl_event_callback_array_add, EFL_EVENT_CALLBACK_DEL, efl_super(), efl_wref_add(), EINA_MAIN_LOOP_CHECK_RETURN, EINA_TRUE, EINA_UNUSED, and ERR.
char* ecore_timer_dump | ( | void | ) |
This function returns a human readable text-based log for Ecore_Timer events.
free
.It only contains an useful implementation if EFL is built in debug build profile, but it's safe to call it for any build profile.
References efl_data_scope_get(), efl_event_callback_call(), efl_ref(), efl_super(), efl_unref(), eina_evlog(), EINA_FALSE, eina_inlist_append_relative(), eina_inlist_first(), EINA_INLIST_FOREACH, EINA_INLIST_GET, eina_inlist_prepend(), eina_inlist_remove(), EINA_INLIST_REVERSE_FOREACH, EINA_TRUE, EINA_UNLIKELY, EINA_UNUSED, and ERR.
Ecore_Timer* ecore_timer_add | ( | double | in, |
Ecore_Task_Cb | func, | ||
const void * | data | ||
) |
Creates a timer to call the given function in the given period of time.
in | The interval in seconds. |
func | The given function. If func returns 1 , the timer is rescheduled for the next interval in . |
data | Data to pass to func when it is called. |
NULL
on failure.This function adds a timer and returns its handle on success and NULL
on failure. The function func
will be called every in
seconds. The function will be passed the data
pointer as its parameter.
When the timer func
is called, it must return a value of either 1
(or ECORE_CALLBACK_RENEW
) or 0
(or ECORE_CALLBACK_CANCEL
). 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 efl_add, efl_event_callback_array_add, EINA_MAIN_LOOP_CHECK_RETURN_VAL, and ERR.
Referenced by elm_entry_file_get(), elm_image_animated_get(), and elm_transit_go_in().
Ecore_Timer* ecore_timer_loop_add | ( | double | in, |
Ecore_Task_Cb | func, | ||
const void * | data | ||
) |
Creates a timer to call the given function in the given period of time.
in | The interval in seconds from current loop time. |
func | The given function. If func returns 1, the timer is rescheduled for the next interval in . |
data | Data to pass to func when it is called. |
NULL
on failure.This is the same as ecore_timer_add(), but "now" is the time from ecore_loop_time_get() not ecore_time_get() as ecore_timer_add() uses. See ecore_timer_add() for more details.
References efl_add, efl_event_callback_array_add, EINA_MAIN_LOOP_CHECK_RETURN_VAL, and ERR.
void* ecore_timer_del | ( | Ecore_Timer * | timer | ) |
Deletes the specified timer from the timer list.
timer | The timer to delete. |
NULL
is returned if the function is unsuccessful.Note: timer
must be a valid handle. If the timer function has already returned 0
, the handle is no longer valid (and does not need to be delete).
References ecore_time_get(), efl_del(), efl_key_data_get(), efl_unref(), EINA_MAIN_LOOP_CHECK_RETURN_VAL, EINA_TRUE, EINA_UNUSED, and ERR.
Referenced by ecore_avahi_del(), ecore_poller_del(), elm_entry_file_get(), elm_entry_file_set(), elm_image_animated_get(), elm_transit_go(), and elm_transit_go_in().