Tizen Native API

Ecore provides very flexible timer functionality.

The basic usage of timers is to call a certain function at a certain interval, which can be achieved with a single line:

 Eina_Bool my_func(void *data) {
    do_funky_stuff_with_data(data);
    return ECORE_CALLBACK_RENEW;
 }
 ecore_timer_add(interval_in_seconds, my_func, data_given_to_function);

If the function is to be executed only once simply return CORE_CALLBACK_CANCEL instead.

Functions

Ecore_Timerecore_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.
Ecore_Timerecore_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.
void * ecore_timer_del (Ecore_Timer *timer)
 Deletes the specified timer from the timer list.
void ecore_timer_interval_set (Ecore_Timer *timer, double in)
 Change the interval the timer ticks off.
double ecore_timer_interval_get (Ecore_Timer *timer)
 Get the interval the timer ticks on.
void ecore_timer_freeze (Ecore_Timer *timer)
 Pauses a running timer.
void ecore_timer_thaw (Ecore_Timer *timer)
 Resumes a frozen (paused) timer.
void ecore_timer_delay (Ecore_Timer *timer, double add)
 Add some delay for the next occurrence of a timer.
void ecore_timer_reset (Ecore_Timer *timer)
 Reset a timer to its full interval. This effectively makes the timer start ticking off from zero now.
double ecore_timer_pending_get (Ecore_Timer *timer)
 Get the pending time regarding a timer.
double ecore_timer_precision_get (void)
 Retrieves the current precision used by timer infrastructure.
void ecore_timer_precision_set (double precision)
 Sets the precision to be used by timer infrastructure.
char * ecore_timer_dump (void)
 Dump the all timers.

Typedefs

typedef struct _Ecore_Timer Ecore_Timer
 A handle for timers.

Function Documentation

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.

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.

Since :
2.3.1
Remarks:
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.
Parameters:
[in]inThe interval in seconds.
[in]funcThe given function. If func returns 1, the timer is rescheduled for the next interval in.
[in]dataData to pass to func when it is called.
Returns:
A timer object on success. NULL on failure.
void* ecore_timer_del ( Ecore_Timer timer)

Deletes the specified timer from the timer list.

This deletes the specified timer from the set of timer that are executed during main loop execution. This function returns the data parameter that is being passed to the callback on success, otherwise NULL on failure.

Since :
2.3.1
Parameters:
[in]timerThe timer to delete
Returns:
The data pointer set for the timer on add
void ecore_timer_delay ( Ecore_Timer timer,
double  add 
)

Add some delay for the next occurrence of a timer.

Since :
2.3.1
Remarks:
This doesn't affect the interval of a timer.
Parameters:
[in]timerThe timer to change.
[in]addThe delay to add to the next iteration.
char* ecore_timer_dump ( void  )

Dump the all timers.

Since :
2.3.1
Returns:
The information of all timers
void ecore_timer_freeze ( Ecore_Timer timer)

Pauses a running timer.

Since :
2.3.1
Remarks:
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.
Nothing happens if the timer was already paused.
Parameters:
[in]timerThe timer to be paused.
See also:
ecore_timer_thaw()

Get the interval the timer ticks on.

Since :
2.3.1
Parameters:
[in]timerThe timer to retrieve the interval from
Returns:
The interval on success. -1 on failure.
void ecore_timer_interval_set ( Ecore_Timer timer,
double  in 
)

Change the interval the timer ticks off.

Since :
2.3.1
Parameters:
[in]timerThe timer to change.
[in]inThe interval in seconds.
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.

Since :
2.3.1
Remarks:
This is same as ecore_timer_add(), but "now" is the time from ecore_loop_time_get(), not ecore_time_get(), as ecore_timer_add() uses it. See ecore_timer_add() for more details.
Parameters:
[in]inThe interval in seconds from the current loop time
[in]funcThe given function
If func returns 1, the timer is rescheduled for the next interval in.
[in]dataThe data to pass to func when it is called
Returns:
A timer object on success, otherwise NULL on failure
double ecore_timer_pending_get ( Ecore_Timer timer)

Get the pending time regarding a timer.

Parameters:
[in]timerThe timer
Returns:
The pending time
Since :
2.3.1
double ecore_timer_precision_get ( void  )

Retrieves the current precision used by timer infrastructure.

Since :
2.3.1
Returns:
Current precision.
See also:
ecore_timer_precision_set()
void ecore_timer_precision_set ( double  precision)

Sets the precision to be used by timer infrastructure.

Since :
2.3.1
Remarks:
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.
Ecore is smart enough to see if there are timers in the precision range, if it does not, in our example if no second timer in (T + precision) existed, then it would use the minimum timeout.
Parameters:
[in]precisiondifference from the requested internval.
void ecore_timer_reset ( Ecore_Timer timer)

Reset a timer to its full interval. This effectively makes the timer start ticking off from zero now.

Parameters:
[in]timerThe timer
Since :
2.3.1
void ecore_timer_thaw ( Ecore_Timer timer)

Resumes a frozen (paused) timer.

Since :
2.3.1
Remarks:
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().
Parameters:
[in]timerThe timer to be resumed.
See also:
ecore_timer_freeze()