{
if (!animator->delete_me && !animator->suspended)
{
- Ecore_Task_Cb func;
- void *data;
- Eina_Bool ret;
-
- func = animator->func;
- data = animator->data;
- _ecore_unlock();
- ret = func(data);
- _ecore_lock();
-
- if (!ret)
+ if (!_ecore_call_task_cb(animator->func, animator->data))
{
animator->delete_me = EINA_TRUE;
animators_delete_me++;
void *data;
data = event->data;
- if (event->func_free)
- {
- Ecore_End_Cb func_free;
- void *ev;
- void *data;
-
- func_free = event->func_free;
- ev = event->event;
- data = event->data;
-
- _ecore_unlock();
- func_free(data, ev);
- _ecore_lock();
- }
+ if (event->func_free) _ecore_call_end_cb(event->func_free, event->data, event->event);
events = (Ecore_Event *) eina_inlist_remove(EINA_INLIST_GET(events), EINA_INLIST_GET(event));
ECORE_MAGIC_SET(event, ECORE_MAGIC_NONE);
free(event);
ef->references++;
if (ef->func_start)
- {
- Ecore_Data_Cb func_start;
- void *data;
- void *r;
-
- func_start = ef->func_start;
- data = ef->data;
- _ecore_unlock();
- r = func_start(data);
- _ecore_lock();
- ef->loop_data = r;
- }
+ ef->loop_data = _ecore_call_data_cb(ef->func_start, ef->data);
if (!event_filter_event_current)
{
while (event_filter_event_current)
{
Ecore_Event *e = event_filter_event_current;
- Ecore_Filter_Cb func_filter;
- void *loop_data;
- void *data;
- int type;
- void *event;
- Eina_Bool r;
-
- func_filter = ef->func_filter;
- data = ef->data;
- loop_data = ef->loop_data;
- type = e->type;
- event = e->event;
-
- _ecore_unlock();
- r = func_filter(data, loop_data, type, event);
- _ecore_lock();
- if (!r)
+
+ if (!_ecore_call_filter_cb(ef->func_filter, ef->data,
+ ef->loop_data, e->type, e->event))
{
ecore_event_del(e);
}
event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next;
}
if (ef->func_end)
- {
- Ecore_End_Cb func_end;
- void *loop_data;
- void *data;
-
- func_end = ef->func_end;
- data = ef->data;
- loop_data = ef->loop_data;
-
- _ecore_unlock();
- ef->func_end(ef->data, ef->loop_data);
- _ecore_lock();
- }
+ _ecore_call_end_cb(ef->func_end, ef->data, ef->loop_data);
ef->references--;
}
eh = event_handler_current;
if (!eh->delete_me)
{
- Ecore_Event_Handler_Cb func;
- void *data;
- int type;
- void *event;
Eina_Bool ret;
handle_count++;
- func = eh->func;
- data = eh->data;
- type = e->type;
- event = e->event;
eh->references++;
- _ecore_unlock();
- ret = func(data, type, event);
- _ecore_lock();
+ ret = _ecore_call_handler_cb(eh->func, eh->data, e->type, e->event);
eh->references--;
if (!ret)
Ecore_Idle_Enterer *ie = (Ecore_Idle_Enterer *)idle_enterer_current;
if (!ie->delete_me)
{
- Ecore_Task_Cb func;
- void *data;
- Eina_Bool ret;
-
- func = ie->func;
- data = ie->data;
ie->references++;
- _ecore_unlock();
- ret = func(data);
- _ecore_lock();
- if (!ret)
+ if (!_ecore_call_task_cb(ie->func, ie->data))
{
if (!ie->delete_me) _ecore_idle_enterer_del(ie);
}
Ecore_Idle_Exiter *ie = (Ecore_Idle_Exiter *)idle_exiter_current;
if (!ie->delete_me)
{
- Ecore_Task_Cb func;
- void *data;
- Eina_Bool ret;
-
- func = ie->func;
- data = ie->data;
ie->references++;
- _ecore_unlock();
- ret = func(data);
- _ecore_lock();
- if (!ret)
+ if (!_ecore_call_task_cb(ie->func, ie->data))
{
if (!ie->delete_me) _ecore_idle_exiter_del(ie);
}
Ecore_Idler *ie = (Ecore_Idler *)idler_current;
if (!ie->delete_me)
{
- Eina_Bool ret;
- Ecore_Task_Cb func;
- void *data;
-
- func = ie->func;
- data = ie->data;
ie->references++;
- _ecore_unlock();
- ret = func(data);
- _ecore_lock();
- if (!ret)
+ if (!_ecore_call_task_cb(ie->func, ie->data))
{
if (!ie->delete_me) _ecore_idler_del(ie);
}
}
if (!fdh->delete_me && fdh->prep_func)
{
- Ecore_Fd_Prep_Cb prep_func;
- void *prep_data;
-
- prep_func = fdh->prep_func;
- prep_data = fdh->prep_data;
fdh->references++;
- _ecore_unlock();
- prep_func(prep_data, fdh);
- _ecore_lock();
+ _ecore_call_prep_cb(fdh->prep_func, fdh->prep_data, fdh);
fdh->references--;
}
else
ERR("Found bad fd at index %d", fdh->fd);
if (fdh->flags & ECORE_FD_ERROR)
{
- Eina_Bool ret;
ERR("Fd set for error! calling user");
fdh->references++;
- _ecore_unlock();
- ret = fdh->func(fdh->data, fdh);
- _ecore_lock();
- if (!ret)
+ if (!_ecore_call_fd_cb(fdh->func, fdh->data, fdh))
{
ERR("Fd function err returned 0, remove it");
if (!fdh->delete_me)
(fdh->write_active) ||
(fdh->error_active))
{
- Eina_Bool ret;
fdh->references++;
- _ecore_unlock();
- ret = fdh->func(fdh->data, fdh);
- _ecore_lock();
- if (!ret)
+ if (!_ecore_call_fd_cb(fdh->func, fdh->data, fdh))
{
if (!fdh->delete_me)
{
}
if ((!fdh->delete_me) && fdh->buf_func)
{
- Ecore_Fd_Cb buf_func;
- void *buf_data;
- Eina_Bool r;
-
- /* copy data before releasing lock */
- buf_func = fdh->buf_func;
- buf_data = fdh->buf_data;
fdh->references++;
- _ecore_unlock();
- r = buf_func(buf_data, fdh);
- _ecore_lock();
- if (r)
+ if (_ecore_call_fd_cb(fdh->buf_func, fdh->buf_data, fdh))
{
- Ecore_Fd_Cb func;
- void *data;
-
- func = fdh->func;
- data = fdh->data;
- _ecore_unlock();
- ret |= func(data, fdh);
- _ecore_lock();
+ ret |= _ecore_call_fd_cb(fdh->func, fdh->data, fdh);
fdh->read_active = EINA_TRUE;
_ecore_try_add_to_call_list(fdh);
}
void _ecore_lock(void);
void _ecore_unlock(void);
#else
-static inline void _ecore_lock(void)
- {
- /* at least check we're not being called from a thread */
- EINA_MAIN_LOOP_CHECK_RETURN;
- }
-
-static inline void _ecore_unlock(void)
- {
- }
+static inline void
+_ecore_lock(void)
+{
+ /* at least check we're not being called from a thread */
+ EINA_MAIN_LOOP_CHECK_RETURN;
+}
+
+static inline void
+_ecore_unlock(void)
+{
+}
#endif
+/*
+ * Callback wrappers all assume that ecore _ecore_lock has been called
+ */
+static inline Eina_Bool
+_ecore_call_task_cb(Ecore_Task_Cb func, void *data)
+{
+ Eina_Bool r;
+
+ _ecore_unlock();
+ r = func(data);
+ _ecore_lock();
+
+ return r;
+}
+
+static inline void *
+_ecore_call_data_cb(Ecore_Data_Cb func, void *data)
+{
+ void *r;
+
+ _ecore_unlock();
+ r = func(data);
+ _ecore_lock();
+
+ return r;
+}
+
+static inline void
+_ecore_call_end_cb(Ecore_End_Cb func, void *user_data, void *func_data)
+{
+ _ecore_unlock();
+ func(user_data, func_data);
+ _ecore_lock();
+}
+
+static inline Eina_Bool
+_ecore_call_filter_cb(Ecore_Filter_Cb func, void *data,
+ void *loop_data, int type, void *event)
+{
+ Eina_Bool r;
+
+ _ecore_unlock();
+ r = func(data, loop_data, type, event);
+ _ecore_lock();
+
+ return r;
+}
+
+static inline Eina_Bool
+_ecore_call_handler_cb(Ecore_Event_Handler_Cb func, void *data, int type, void *event)
+{
+ Eina_Bool r;
+
+ _ecore_unlock();
+ r = func(data, type, event);
+ _ecore_lock();
+
+ return r;
+}
+
+static inline void
+_ecore_call_prep_cb(Ecore_Fd_Prep_Cb func, void *data, Ecore_Fd_Handler *fd_handler)
+{
+ _ecore_unlock();
+ func(data, fd_handler);
+ _ecore_lock();
+}
+
+static inline Eina_Bool
+_ecore_call_fd_cb(Ecore_Fd_Cb func, void *data, Ecore_Fd_Handler *fd_handler)
+{
+ Eina_Bool r;
+
+ _ecore_unlock();
+ r = func(data, fd_handler);
+ _ecore_lock();
+
+ return r;
+}
+
extern int _ecore_fps_debug;
extern double _ecore_time_loop_time;
extern Eina_Bool _ecore_glib_always_integrate;
while (timer_current)
{
Ecore_Timer *timer = timer_current;
- Eina_Bool cont;
- Ecore_Task_Cb func;
- void *data;
if (timer->at > when)
{
}
timer->references++;
- func = timer->func;
- data = timer->data;
- _ecore_unlock();
- cont = func(data);
- _ecore_lock();
- if (!cont)
+ if (!_ecore_call_task_cb(timer->func, timer->data))
{
if (!timer->delete_me) _ecore_timer_del(timer);
}