111 lines
3.8 KiB
Plaintext
111 lines
3.8 KiB
Plaintext
===== Javascript binding API - Ecore Timer =====
|
|
|
|
[[api:javascript:ecore|Back to the JS Ecore page]]
|
|
|
|
**DRAFT**
|
|
|
|
The Timer module provides flexible timer functionality.
|
|
|
|
==== Functions ====
|
|
|
|
=== add(time, callback) ===
|
|
|
|
Syntax
|
|
|
|
<code javascript>
|
|
function mycallback() { ... };
|
|
var timerObj = efl.Ecore.Timer.add(time, mycallback);
|
|
</code>
|
|
|
|
Parameters
|
|
|
|
* time - A number with the time, in seconds, with the interval between consecutive activation of the timer.
|
|
* callback - A function taking no arguments to be called when the timer is triggered. It must return either ''efl.Ecore.Mainloop.RENEW'' (or 1) or ''efl.Ecore.Mainloop.Cancel'' (or 0). If it returns the former, it will be called again on the next tick (according to ''time''). If it returns the latter, it will be deleted automatically, making any references to the timer invalid.
|
|
|
|
Return value
|
|
|
|
* object - An object wrapping the newly created timer.
|
|
* null - If it was not possible to add the timer.
|
|
|
|
Adds a new timer that will call ''callback'' after ''time'' seconds.
|
|
|
|
=== addLoop(time, callback) ===
|
|
|
|
Syntax
|
|
|
|
<code javascript>
|
|
function mycallback() { ... };
|
|
var timerObj = efl.Ecore.Timer.addLoop(time, mycallback);
|
|
</code>
|
|
|
|
Parameters
|
|
|
|
* time - A number with the time, in seconds, with the interval between consecutive activation of the timer.
|
|
* callback - A function taking no arguments to be called when the timer is triggered. It must return either ''efl.Ecore.Mainloop.RENEW'' (or 1) or ''efl.Ecore.Mainloop.Cancel'' (or 0). If it returns the former, it will be called again on the next tick (according to ''time''). If it returns the latter, it will be deleted automatically, making any references to the timer invalid.
|
|
|
|
Return value
|
|
|
|
* object - An object wrapping the newly created timer.
|
|
* null - If it was not possible to add the timer.
|
|
|
|
Works like ''efl.Ecore.Timer.add'', but the reference "now" time is the time that the main loop ceased waiting for timeouts and/or events to come in or for signals or any other interrupt source. Use this UNLESS you absolutely must get the current actual timepoint.
|
|
|
|
=== timerObj.del() ===
|
|
|
|
Syntax
|
|
|
|
<code javascript>
|
|
timerObj.del();
|
|
</code>
|
|
|
|
Deletes the callee timer object from the list of active timers.
|
|
|
|
=== dump() ===
|
|
|
|
Syntax
|
|
|
|
<code javascript>
|
|
var log = efl.Ecore.Timer.dump();
|
|
</code>
|
|
|
|
Return value
|
|
|
|
* string - The human-readable log.
|
|
|
|
This function returns a human-readable text-based log for Ecore Timer events.
|
|
|
|
=== getPrecision() ===
|
|
|
|
Syntax
|
|
|
|
<code javascript>
|
|
var precision = efl.Ecore.Timer.getPrecision();
|
|
</code>
|
|
|
|
Return value
|
|
|
|
* number - The current precision for all timers.
|
|
|
|
Retrieves the current precision used by timer infrastructure.
|
|
|
|
=== setPrecision(precision) ===
|
|
|
|
Syntax
|
|
|
|
<code javascript>
|
|
efl.Ecore.Timer.setPrecision(precision);
|
|
</code>
|
|
|
|
Parameters
|
|
|
|
* precision - A number with the allowed introduced timeout delay, in seconds.
|
|
|
|
This sets the precision for **all** timers. The precision determines how much of a difference from the requested interval is acceptable. One common reason to use this function is to **increase** the allowed timeout and thus, **decrease** the precision of the timers, this is because less precise the timers result in the system waking up less often and thus consuming fewer 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.
|
|
|
|
<note important>
|
|
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.
|
|
</note> |