DRAFT
The Poller module provides infrastructure for 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: efl.Ecore.Poller.CORE
, the default interval for efl.Ecore.Poller.CORE
is 0.125(or 1/8th) second.
The creation of a poller is extremely simple and only requires one line:
efl.Ecore.Poller.add(efl.Ecore.Poller.CORE, 1, my_poller_function);
This sample creates a poller to call my_poller_function at every tick.
efl.Ecore.Poller.CORE
- The default poller type.Syntax
function mycallback() { ...}; var poller = efl.Ecore.Poller.add(pollerType, interval, mycallback);
Parameters
efl.Ecore.Poller.CORE
callback
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.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 interval
). If it returns the latter, it will be deleted automatically, making any references to the poller invalid.Return value
Syntax
pollerObj.del();
Deletes the callee poller object from the pollers list.
Syntax
var interval = efl.Ecore.Poller.getPollInterval(type);
Parameters
efl.Ecore.Poller.CORE
.Return value
Gets the interval in seconds between successive ticks of the given poller type.
Syntax
efl.Ecore.Poller.setPollInterval(type, poll_time);
Parameters
efl.Ecore.Poller.CORE
.
Sets the interval (in seconds) between successive ticks for the poller type type
.