- Main Page
- Related Pages
- Modules
- Data Structures
- Files
- Examples

Typedefs | Enumerations | Functions
Ecore Poll functions
Ecore main loop

Ecore poller provides infrastructure for the creation of pollers. More...

## Typedefs
typedef enum _Ecore_Poller_Type | Ecore_Poller_Type
typedef Eo | Ecore_Poller
| A handle for pollers.

## Enumerations
enum | _Ecore_Poller_Type { ECORE_POLLER_CORE = 0 }
| Defines the frequency of ticks for the poller. More...

## Functions
void | ecore_poller_poll_interval_set (Ecore_Poller_Type type, double poll_time)
| Sets the time(in seconds) between ticks for the given poller type. More...
double | ecore_poller_poll_interval_get (Ecore_Poller_Type type)
| Gets the time(in seconds) between ticks for the given poller type. More...
enum | { ECORE_POLLER_SUB_ID_CONSTRUCTOR, ECORE_POLLER_SUB_ID_INTERVAL_SET, ECORE_POLLER_SUB_ID_INTERVAL_GET, ECORE_POLLER_SUB_ID_LAST }
const Eo_Class * | ecore_poller_class_get (void)
#define | ECORE_POLLER_CLASS ecore_poller_class_get()
#define | ECORE_POLLER_ID(sub_id) (ECORE_POLLER_BASE_ID + sub_id)
#define | ecore_poller_constructor(type, interval, func, data) ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Poller_Type, type), EO_TYPECHECK(int, interval), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
#define | ecore_poller_interval_set(interval, ret) ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_INTERVAL_SET), EO_TYPECHECK(int, interval), EO_TYPECHECK(Eina_Bool *, ret)
#define | ecore_poller_interval_get(ret) ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_INTERVAL_GET), EO_TYPECHECK(int *, ret)
Eo_Op | ECORE_POLLER_BASE_ID
Eina_Bool | ecore_poller_poller_interval_set (Ecore_Poller *poller, int interval)
| Changes the polling interval rate of `poller`. More...
int | ecore_poller_poller_interval_get (Ecore_Poller *poller)
| Gets the polling interval rate of `poller`. More...
Ecore_Poller * | ecore_poller_add (Ecore_Poller_Type type, int interval, Ecore_Task_Cb func, const void *data)
| Creates a poller to call the given function at a particular tick interval. More...
void * | ecore_poller_del (Ecore_Poller *poller)
| Delete the specified poller from the timer list. More...

## Detailed Description

Ecore poller provides infrastructure for the 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: ECORE_POLLER_CORE, the default interval for ECORE_POLLER_CORE is 0.125(or 1/8th) second.

The creation of a poller is extremely simple and only requires one line:

ecore_poller_add(ECORE_POLLER_CORE, 1, my_poller_function, NULL);

This sample creates a poller to call `my_poller_function` at every tick with `NULL` as data.

Example:

- ecore poller - Repetitive polling tasks

## Macro Definition Documentation

#define ecore_poller_constructor | ( |  | type,
|  |  | interval,
|  |  | func,
|  |  | data
| ) |  | ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Poller_Type, type), EO_TYPECHECK(int, interval), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)

Since
  1.8

Contructor with parameters for Ecore Poller.

Parameters

  [in] | type |
  [in] | interval |
  [in] | func |
  [in] | data |

Referenced by ecore_poller_add().

#define ecore_poller_interval_set | ( |  | interval,
|  |  | ret
| ) |  | ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_INTERVAL_SET), EO_TYPECHECK(int, interval), EO_TYPECHECK(Eina_Bool *, ret)

Since
  1.8

Changes the polling interval rate of poller.

Parameters

  [in] | interval |
  [out] | ret |

See Also
  ecore_poller_poller_interval_set

Referenced by ecore_poller_poller_interval_set().

#define ecore_poller_interval_get | ( |  | ret | ) | ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_INTERVAL_GET), EO_TYPECHECK(int *, ret)

Since
  1.8

Gets the polling interval rate of poller.

Parameters

  [out] | ret |

See Also
  ecore_poller_poller_interval_get

Referenced by ecore_poller_poller_interval_get().

## Enumeration Type Documentation

enum _Ecore_Poller_Type

Defines the frequency of ticks for the poller.

Enumerator
ECORE_POLLER_CORE | The core poller interval.

## Function Documentation

void ecore_poller_poll_interval_set | ( | Ecore_Poller_Type | type,
|  | double | poll_time
| ) |  |

Sets the time(in seconds) between ticks for the given poller type.

Parameters

  type | The poller type to adjust.
  poll_time | The time(in seconds) between ticks of the timer.

This will adjust the time between ticks of the given timer type defined by `type` to the time period defined by `poll_time`.

Examples:
  ecore_poller_example.c.

References EINA_MAIN_LOOP_CHECK_RETURN.

double ecore_poller_poll_interval_get | ( | Ecore_Poller_Type | type | ) |

Gets the time(in seconds) between ticks for the given poller type.

Parameters

  type | The poller type to query.

Returns
  The time in seconds between ticks of the poller timer.

This will get the time between ticks of the specified poller timer.

References EINA_MAIN_LOOP_CHECK_RETURN_VAL.

Eina_Bool ecore_poller_poller_interval_set | ( | Ecore_Poller * | poller,
|  | int | interval
| ) |  |

Changes the polling interval rate of `poller`.

Parameters

  poller | The Ecore_Poller to change the interval of.
  interval | The tick interval to set; must be a power of 2 and <= 32768.

Returns
  Returns true on success, false on failure.

This allows the changing of a poller's polling interval. It is useful when you want to alter a poll rate without deleting and re-creating a poller.

Examples:
  ecore_poller_example.c.

References ecore_poller_interval_set, and EINA_FALSE.

int ecore_poller_poller_interval_get | ( | Ecore_Poller * | poller | ) |

Gets the polling interval rate of `poller`.

Parameters

  poller | The Ecore_Poller to change the interval of.

Returns
  Returns the interval, in ticks, that `poller` polls at.

This returns a poller's polling interval, or 0 on error.

References ecore_poller_interval_get, and EINA_FALSE.

Ecore_Poller* ecore_poller_add | ( | Ecore_Poller_Type | type,
|  | int | interval,
|  | Ecore_Task_Cb | func,
|  | const void * | data
| ) |  |

Creates a poller to call the given function at a particular tick interval.

Parameters

  type | The ticker type to attach the poller to. Must be ECORE_POLLER_CORE.
  interval | The poll interval.
  func | The poller function.
  data | Data to pass to func when it is called.

Returns
  A poller object on success, `NULL` otherwise.

This function adds func as a poller callback that will be called every interval ticks together with other pollers of type type. func will be passed the `data` pointer as a parameter.

The `interval` must be between 1 and 32768 inclusive, and must be a power of 2 (i.e. 1, 2, 4, 8, 16, ... 16384, 32768). The exact tick in which func 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.

When the poller `func` is called, it must return a value of either ECORE_CALLBACK_RENEW(or 1) or ECORE_CALLBACK_CANCEL(or 0). 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.

Examples:
  ecore_poller_example.c.

References ecore_poller_constructor.

void* ecore_poller_del | ( | Ecore_Poller * | poller | ) |

Delete the specified poller from the timer list.

Parameters

  poller | The poller to delete.

Returns
  The data pointer set for the timer when ecore_poller_add was called on success, `NULL` otherwise.

Note
  poller must be a valid handle. If the poller function has already returned 0, the handle is no longer valid (and does not need to be deleted).

Examples:
  ecore_poller_example.c.

References EINA_FALSE, EINA_INLIST_GET, eina_inlist_remove(), and EINA_MAIN_LOOP_CHECK_RETURN_VAL.