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 value) |
Sets the precision to be used by timer infrastructure. More... | |
char * | ecore_timer_dump (void) |
static Eina_Bool | _ecore_timer_add (Ecore_Timer *obj, Ecore_Timer_Private_Data *timer, double now, double in, Ecore_Task_Cb func, const void *data) |
static void | _timer_constructor (Eo *obj, void *_pd, va_list *list) |
static void | _timer_loop_constructor (Eo *obj, void *_pd, va_list *list) |
static void | _constructor (Eo *obj, void *_pd, va_list *list) |
EAPI 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... | |
EAPI void * | ecore_timer_del (Ecore_Timer *timer) |
Delete the specified timer from the timer list. More... | |
EAPI void | ecore_timer_interval_set (Ecore_Timer *timer, double in) |
Change the interval the timer ticks of. More... | |
static void | _timer_interval_set (Eo *obj, void *_pd, va_list *list) |
EAPI double | ecore_timer_interval_get (Ecore_Timer *timer) |
Get the interval the timer ticks on. More... | |
static void | _timer_interval_get (Eo *obj, void *_pd, va_list *list) |
EAPI void | ecore_timer_delay (Ecore_Timer *timer, double add) |
Add some delay for the next occurrence of a timer. More... | |
static void | _timer_delay (Eo *obj, void *_pd, va_list *list) |
EAPI void | ecore_timer_reset (Ecore_Timer *timer) |
Reset a timer to its full interval This doesn't affect the interval of a timer. More... | |
static void | _timer_reset (Eo *obj, void *_pd, va_list *list) |
EAPI double | ecore_timer_pending_get (Ecore_Timer *timer) |
Get the pending time regarding a timer. More... | |
static void | _timer_pending_get (Eo *obj, void *_pd, va_list *list) |
EAPI void | ecore_timer_freeze (Ecore_Timer *timer) |
Pauses a running timer. More... | |
static void | _timer_freeze (Eo *obj, void *_pd, va_list *list) |
EAPI void | ecore_timer_thaw (Ecore_Timer *timer) |
Resumes a frozen (paused) timer. More... | |
static void | _timer_thaw (Eo *obj, void *_pd, va_list *list) |
const Eo_Class * | ecore_timer_class_get (void) |
#define | ECORE_TIMER_CLASS ecore_timer_class_get() |
#define | ECORE_TIMER_ID(sub_id) (ECORE_TIMER_BASE_ID + sub_id) |
#define | ecore_timer_constructor(in, func, data) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(double, in), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data) |
#define | ecore_timer_loop_constructor(in, func, data) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_LOOP_CONSTRUCTOR), EO_TYPECHECK(double, in), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data) |
#define | ecore_obj_timer_interval_set(in) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_INTERVAL_SET), EO_TYPECHECK(double, in) |
#define | ecore_obj_timer_interval_get(ret) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_INTERVAL_GET), EO_TYPECHECK(double *, ret) |
#define | ecore_obj_timer_delay(add) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_DELAY), EO_TYPECHECK(double, add) |
#define | ecore_obj_timer_reset() ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_RESET) |
#define | ecore_obj_timer_pending_get(ret) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_PENDING_GET), EO_TYPECHECK(double *, ret) |
enum | { ECORE_TIMER_SUB_ID_CONSTRUCTOR, ECORE_TIMER_SUB_ID_LOOP_CONSTRUCTOR, ECORE_TIMER_SUB_ID_INTERVAL_SET, ECORE_TIMER_SUB_ID_INTERVAL_GET, ECORE_TIMER_SUB_ID_DELAY, ECORE_TIMER_SUB_ID_RESET, ECORE_TIMER_SUB_ID_PENDING_GET, ECORE_TIMER_SUB_ID_LAST } |
Eo_Op | ECORE_TIMER_BASE_ID |
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 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:
#define ecore_timer_constructor | ( | in, | |
func, | |||
data | |||
) | ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(double, in), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data) |
#define ecore_timer_loop_constructor | ( | in, | |
func, | |||
data | |||
) | ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_LOOP_CONSTRUCTOR), EO_TYPECHECK(double, in), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data) |
Contructor.
[in] | in | |
[in] | func | |
[in] | data |
#define ecore_obj_timer_interval_set | ( | in | ) | ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_INTERVAL_SET), EO_TYPECHECK(double, in) |
Change the interval the timer ticks of.
[in] | in |
Referenced by ecore_timer_interval_set().
#define ecore_obj_timer_interval_get | ( | ret | ) | ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_INTERVAL_GET), EO_TYPECHECK(double *, ret) |
Get the interval the timer ticks on.
[out] | ret |
Referenced by ecore_timer_interval_get().
#define ecore_obj_timer_delay | ( | add | ) | ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_DELAY), EO_TYPECHECK(double, add) |
Add some delay for the next occurrence of a timer.
[in] | add |
Referenced by ecore_timer_delay().
#define ecore_obj_timer_reset | ( | ) | ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_RESET) |
Reset a timer to its full interval.
Referenced by ecore_timer_reset().
#define ecore_obj_timer_pending_get | ( | ret | ) | ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_PENDING_GET), EO_TYPECHECK(double *, ret) |
Get the pending time regarding a timer.
[out] | ret |
Referenced by ecore_timer_pending_get().
EAPI double ecore_timer_precision_get | ( | void | ) |
Retrieves the current precision used by timer infrastructure.
References EINA_MAIN_LOOP_CHECK_RETURN_VAL.
EAPI void ecore_timer_precision_set | ( | double | value | ) |
Sets the precision to be used by timer infrastructure.
value | 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 EINA_MAIN_LOOP_CHECK_RETURN.
EAPI 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 ecore_timer_constructor, and EINA_MAIN_LOOP_CHECK_RETURN_VAL.
Referenced by ecore_con_url_timeout_set(), ecore_exe_kill(), and ecore_init().
EAPI 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.
EAPI void* ecore_timer_del | ( | Ecore_Timer * | timer | ) |
Delete 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 EINA_MAIN_LOOP_CHECK_RETURN_VAL.
Referenced by ecore_con_url_free(), ecore_con_url_shutdown(), ecore_con_url_timeout_set(), ecore_exe_free(), ecore_exe_kill(), and ecore_shutdown().
EAPI void ecore_timer_interval_set | ( | Ecore_Timer * | timer, |
double | in | ||
) |
Change the interval the timer ticks of.
If set during a timer call, this will affect the next interval.
timer | The timer to change. |
in | The interval in seconds. |
References ecore_obj_timer_interval_set.
EAPI double ecore_timer_interval_get | ( | Ecore_Timer * | timer | ) |
Get the interval the timer ticks on.
timer | The timer to retrieve the interval from |
References ecore_obj_timer_interval_get.
EAPI void ecore_timer_delay | ( | Ecore_Timer * | timer, |
double | add | ||
) |
Add some delay for the next occurrence of a timer.
This doesn't affect the interval of a timer.
timer | The timer to change. |
add | The delay to add to the next iteration. |
References ecore_obj_timer_delay.
EAPI void ecore_timer_reset | ( | Ecore_Timer * | timer | ) |
Reset a timer to its full interval This doesn't affect the interval of a timer.
timer | The timer |
References ecore_obj_timer_reset.
EAPI double ecore_timer_pending_get | ( | Ecore_Timer * | timer | ) |
Get the pending time regarding a timer.
timer | The timer to learn from. |
References ecore_obj_timer_pending_get.
EAPI void ecore_timer_freeze | ( | Ecore_Timer * | timer | ) |
Pauses a running timer.
timer | The timer to be paused. |
The timer callback won't be called while the timer is paused. The remaining time until the timer expires will be saved, so the timer can be resumed with that same remaining time to expire, instead of expiring instantly. Use ecore_timer_thaw() to resume it.
EAPI void ecore_timer_thaw | ( | Ecore_Timer * | timer | ) |
Resumes a frozen (paused) timer.
timer | The timer to be resumed. |
The timer will be resumed from its previous relative position in time. That means, if it had X seconds remaining until expire when it was paused, it will be started now with those same X seconds remaining to expire again. But notice that the interval time won't be touched by this call or by ecore_timer_freeze().