static Eina_Bool _ecore_timer_add(Ecore_Timer *obj, Ecore_Timer_Private_Data *timer, double now, double in, Ecore_Task_Cb func, const void *data) { if (EINA_UNLIKELY(!eina_main_loop_is())) { eo_error_set(obj); EINA_MAIN_LOOP_CHECK_RETURN_VAL(EINA_FALSE); } timer->obj = obj; eo_do_super(obj, eo_constructor()); eo_manual_free_set(obj, EINA_TRUE); if (!func) { eo_error_set(obj); ERR("callback function must be set up for an object of class: '%s'", MY_CLASS_NAME); return EINA_FALSE; } if (in < 0.0) in = 0.0; #ifdef WANT_ECORE_TIMER_DUMP timer->timer_bt_num = backtrace((void **)(timer->timer_bt), ECORE_TIMER_DEBUG_BT_NUM); #endif _ecore_timer_set(obj, now + in, in, func, (void *)data); return EINA_TRUE; }
static Eina_Bool _ecore_idle_enterer_add(Ecore_Idle_Enterer *obj, Ecore_Idle_Enterer_Data *ie, Ecore_Task_Cb func, const void *data) { if (EINA_UNLIKELY(!eina_main_loop_is())) { eo_error_set(obj); EINA_MAIN_LOOP_CHECK_RETURN_VAL(EINA_FALSE); } ie->obj = obj; eo_do_super(obj, MY_CLASS, eo_constructor()); eo_manual_free_set(obj, EINA_TRUE); if (!func) { eo_error_set(obj); ERR("callback function must be set up for an object of class: '%s'", MY_CLASS_NAME); return EINA_FALSE; } ie->func = func; ie->data = (void *)data; return EINA_TRUE; }
void _ecore_idler_shutdown(void) { Ecore_Idler_Data *ie; while ((ie = idlers)) { idlers = (Ecore_Idler_Data *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers)); eo_do(ie->obj, eo_parent_set(NULL)); if (eo_destructed_is(ie->obj)) eo_manual_free(ie->obj); else eo_manual_free_set(ie->obj, EINA_FALSE); } idlers_delete_me = 0; idler_current = NULL; }
EOLIAN static void _ecore_idler_constructor(Eo *obj, Ecore_Idler_Data *ie, Ecore_Task_Cb func, const void *data) { if (EINA_UNLIKELY(!eina_main_loop_is())) { EINA_MAIN_LOOP_CHECK_RETURN; } ie->obj = obj; eo_manual_free_set(obj, EINA_TRUE); if (!func) { ERR("callback function must be set up for an object of class: '%s'", MY_CLASS_NAME); return; } ie->func = func; ie->data = (void *)data; idlers = (Ecore_Idler_Data *)eina_inlist_append(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie)); }
int _ecore_idler_all_call(void) { if (!idler_current) { /* regular main loop, start from head */ idler_current = idlers; } else { /* recursive main loop, continue from where we were */ idler_current = (Ecore_Idler_Data *)EINA_INLIST_GET(idler_current)->next; } while (idler_current) { Ecore_Idler_Data *ie = (Ecore_Idler_Data *)idler_current; if (!ie->delete_me) { ie->references++; eina_evlog("+idler", ie, 0.0, NULL); if (!_ecore_call_task_cb(ie->func, ie->data)) { if (!ie->delete_me) _ecore_idler_del(ie->obj); } eina_evlog("-idler", ie, 0.0, NULL); ie->references--; } if (idler_current) /* may have changed in recursive main loops */ idler_current = (Ecore_Idler_Data *)EINA_INLIST_GET(idler_current)->next; } if (idlers_delete_me) { Ecore_Idler_Data *l; int deleted_idlers_in_use = 0; for (l = idlers; l; ) { Ecore_Idler_Data *ie = l; l = (Ecore_Idler_Data *)EINA_INLIST_GET(l)->next; if (ie->delete_me) { if (ie->references) { deleted_idlers_in_use++; continue; } idlers = (Ecore_Idler_Data *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie)); eo_do(ie->obj, eo_parent_set(NULL)); if (eo_destructed_is(ie->obj)) eo_manual_free(ie->obj); else eo_manual_free_set(ie->obj, EINA_FALSE); } } if (!deleted_idlers_in_use) idlers_delete_me = 0; } if (idlers) return 1; return 0; }