1 #include "ecore_private.h"
4 static Ecore_Idler *idlers = NULL;
5 static int idlers_delete_me = 0;
8 * Add an idler handler.
9 * @param func The function to call when idling.
10 * @param data The data to be passed to this @p func call.
11 * @return A idler handle if successfully added. NULL otherwise.
14 * Add an idler handle to the event loop, returning a handle on success and
15 * NULL otherwise. The function @p func will be called repeatedly while
16 * no other events are ready to be processed, as long as it returns 1
17 * (or ECORE_CALLBACK_RENEW). A return of 0 (or ECORE_CALLBACK_CANCEL) deletes
20 * Idlers are useful for progressively prossessing data without blocking.
23 ecore_idler_add(int (*func) (void *data), const void *data)
27 if (!func) return NULL;
28 ie = calloc(1, sizeof(Ecore_Idler));
30 ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLER);
32 ie->data = (void *)data;
33 idlers = _ecore_list2_append(idlers, ie);
38 * Delete an idler callback from the list to be executed.
39 * @param idler The handle of the idler callback to delete
40 * @return The data pointer passed to the idler callback on success. NULL
45 ecore_idler_del(Ecore_Idler *idler)
47 if (!ECORE_MAGIC_CHECK(idler, ECORE_MAGIC_IDLER))
49 ECORE_MAGIC_FAIL(idler, ECORE_MAGIC_IDLER,
59 _ecore_idler_shutdown(void)
66 idlers = _ecore_list2_remove(idlers, ie);
67 ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
74 _ecore_idler_call(void)
78 for (l = (Ecore_List2 *)idlers; l; l = l->next)
82 ie = (Ecore_Idler *)l;
85 if (!ie->func(ie->data)) ecore_idler_del(ie);
90 for (l = (Ecore_List2 *)idlers; l;)
94 ie = (Ecore_Idler *)l;
98 idlers = _ecore_list2_remove(idlers, ie);
99 ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
103 idlers_delete_me = 0;
105 if (idlers) return 1;
110 _ecore_idler_exist(void)
112 if (idlers) return 1;