ecore: remove useless ecore_lock/unlock.

This commit is contained in:
Cedric BAIL 2016-01-14 14:52:37 -08:00
parent c95350016d
commit 8cc6c7561a
11 changed files with 68 additions and 379 deletions

View File

@ -330,15 +330,13 @@ ecore_shutdown(void)
/*
* take a lock here because _ecore_event_shutdown() does callbacks
*/
_ecore_lock();
if (_ecore_init_count <= 0)
{
ERR("Init count not greater than 0 in shutdown.");
_ecore_unlock();
return 0;
}
if (_ecore_init_count-- != _ecore_init_count_threshold)
goto unlock;
goto end;
ecore_system_modules_unload();
@ -430,9 +428,7 @@ ecore_shutdown(void)
eo_unref(_ecore_parent);
eo_shutdown();
unlock:
_ecore_unlock();
end:
return _ecore_init_count;
}

View File

@ -380,9 +380,7 @@ ecore_animator_add(Ecore_Task_Cb func,
EOLIAN static void
_ecore_animator_constructor(Eo *obj, Ecore_Animator_Data *animator, Ecore_Task_Cb func, const void *data)
{
_ecore_lock();
_ecore_animator_add(obj, animator, func, data);
_ecore_unlock();
}
EAPI Ecore_Animator *
@ -399,19 +397,15 @@ ecore_animator_timeline_add(double runtime,
EOLIAN static void
_ecore_animator_timeline_constructor(Eo *obj, Ecore_Animator_Data *animator, double runtime, Ecore_Timeline_Cb func, const void *data)
{
_ecore_lock();
if (runtime <= 0.0) runtime = 0.0;
if (!_ecore_animator_add(obj, animator, _ecore_animator_run, NULL)) goto unlock;
if (!_ecore_animator_add(obj, animator, _ecore_animator_run, NULL)) return;
animator->data = obj;
animator->run_func = func;
animator->run_data = (void *)data;
animator->start = ecore_loop_time_get();
animator->run = runtime;
unlock:
_ecore_unlock();
}
static double
@ -665,13 +659,12 @@ ecore_animator_del(Ecore_Animator *obj)
if (!obj) return NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
Ecore_Animator_Data *animator = eo_data_scope_get(obj, MY_CLASS);
_ecore_lock();
if (!animator) goto unlock;
if (!animator) return NULL;
if (animator->delete_me)
{
data = animator->data;
goto unlock;
goto end;
}
animator->delete_me = EINA_TRUE;
animators_delete_me++;
@ -679,8 +672,7 @@ ecore_animator_del(Ecore_Animator *obj)
data = animator->run_data;
else
data = animator->data;
unlock:
_ecore_unlock();
end:
return data;
}
@ -708,14 +700,11 @@ EAPI void
ecore_animator_frametime_set(double frametime)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
if (frametime < 0.0) frametime = 0.0;
if (animators_frametime == frametime) goto unlock;
if (animators_frametime == frametime) return ;
animators_frametime = frametime;
_end_tick();
if (_have_animators()) _begin_tick();
unlock:
_ecore_unlock();
}
EAPI double
@ -736,16 +725,13 @@ EOLIAN static void
_ecore_animator_eo_base_event_freeze(Eo *obj EINA_UNUSED, Ecore_Animator_Data *animator)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
if (animator->delete_me) goto unlock;
if (animator->delete_me) return ;
if (!animator->suspended)
{
animator->suspended = EINA_TRUE;
animators_suspended++;
if (!_have_animators()) _end_tick();
}
unlock:
_ecore_unlock();
}
EAPI void
@ -760,27 +746,22 @@ _ecore_animator_eo_base_event_thaw(Eo *obj EINA_UNUSED, Ecore_Animator_Data *ani
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
if (animator->delete_me) goto unlock;
if (animator->delete_me) return;
if (animator->suspended)
{
animator->suspended = EINA_FALSE;
animators_suspended--;
if (_have_animators()) _begin_tick();
}
unlock:
_ecore_unlock();
}
EAPI void
ecore_animator_source_set(Ecore_Animator_Source source)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
_end_tick();
src = source;
if (_have_animators()) _begin_tick();
_ecore_unlock();
}
EAPI Ecore_Animator_Source
@ -795,12 +776,10 @@ ecore_animator_custom_source_tick_begin_callback_set(Ecore_Cb func,
const void *data)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
_end_tick();
begin_tick_cb = func;
begin_tick_data = data;
if (_have_animators()) _begin_tick();
_ecore_unlock();
}
EAPI void
@ -808,21 +787,17 @@ ecore_animator_custom_source_tick_end_callback_set(Ecore_Cb func,
const void *data)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
_end_tick();
end_tick_cb = func;
end_tick_data = data;
if (_have_animators()) _begin_tick();
_ecore_unlock();
}
EAPI void
ecore_animator_custom_tick(void)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
if (src == ECORE_ANIMATOR_SOURCE_CUSTOM) _do_tick();
_ecore_unlock();
}
void

View File

@ -80,12 +80,11 @@ ecore_event_handler_add(int type,
Ecore_Event_Handler *eh = NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
if (!func) goto unlock;
if ((type <= ECORE_EVENT_NONE) || (type >= event_id_max)) goto unlock;
if (!func) return NULL;
if ((type <= ECORE_EVENT_NONE) || (type >= event_id_max)) return NULL;
eh = ecore_event_handler_calloc(1);
if (!eh) goto unlock;
if (!eh) return NULL;
ECORE_MAGIC_SET(eh, ECORE_MAGIC_EVENT_HANDLER);
eh->type = type;
eh->func = func;
@ -106,7 +105,7 @@ ecore_event_handler_add(int type,
if (!new_handlers)
{
ecore_event_handler_mp_free(eh);
goto unlock;
return NULL;
}
event_handlers = new_handlers;
for (i = p_alloc_num; i < event_handlers_alloc_num; i++)
@ -118,48 +117,33 @@ ecore_event_handler_add(int type,
else if (type < event_handlers_alloc_num)
event_handlers[type] = (Ecore_Event_Handler *)eina_inlist_append(EINA_INLIST_GET(event_handlers[type]), EINA_INLIST_GET(eh));
unlock:
_ecore_unlock();
return eh;
}
EAPI void *
ecore_event_handler_del(Ecore_Event_Handler *event_handler)
{
void *data = NULL;
if (!event_handler) return NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
if (!ECORE_MAGIC_CHECK(event_handler, ECORE_MAGIC_EVENT_HANDLER))
{
ECORE_MAGIC_FAIL(event_handler, ECORE_MAGIC_EVENT_HANDLER,
"ecore_event_handler_del");
goto unlock;
return NULL;
}
data = _ecore_event_handler_del(event_handler);
unlock:
_ecore_unlock();
return data;
return _ecore_event_handler_del(event_handler);
}
EAPI void *
ecore_event_handler_data_get(Ecore_Event_Handler *eh)
{
void *data = NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
if (!ECORE_MAGIC_CHECK(eh, ECORE_MAGIC_EVENT_HANDLER))
{
ECORE_MAGIC_FAIL(eh, ECORE_MAGIC_EVENT_HANDLER, "ecore_event_handler_data_get");
goto unlock;
return NULL;
}
data = eh->data;
unlock:
_ecore_unlock();
return data;
return eh->data;
}
EAPI void *
@ -169,16 +153,13 @@ ecore_event_handler_data_set(Ecore_Event_Handler *eh,
void *old = NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
if (!ECORE_MAGIC_CHECK(eh, ECORE_MAGIC_EVENT_HANDLER))
{
ECORE_MAGIC_FAIL(eh, ECORE_MAGIC_EVENT_HANDLER, "ecore_event_handler_data_set");
goto unlock;
return NULL;
}
old = eh->data;
eh->data = (void *)data;
unlock:
_ecore_unlock();
return old;
}
@ -196,53 +177,34 @@ ecore_event_add(int type,
Ecore_End_Cb func_free,
void *data)
{
Ecore_Event *event = NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
/* if (!ev) goto unlock; */
if (type <= ECORE_EVENT_NONE) goto unlock;
if (type >= event_id_max) goto unlock;
if (type <= ECORE_EVENT_NONE) return NULL;
if (type >= event_id_max) return NULL;
if ((ev) && (!func_free)) func_free = _ecore_event_generic_free;
event = _ecore_event_add(type, ev, func_free, data);
unlock:
_ecore_unlock();
return event;
return _ecore_event_add(type, ev, func_free, data);
}
EAPI void *
ecore_event_del(Ecore_Event *event)
{
void *data = NULL;
if (!event) return NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
if (!ECORE_MAGIC_CHECK(event, ECORE_MAGIC_EVENT))
{
ECORE_MAGIC_FAIL(event, ECORE_MAGIC_EVENT, "ecore_event_del");
goto unlock;
return NULL;
}
EINA_SAFETY_ON_TRUE_GOTO(event->delete_me, unlock);
EINA_SAFETY_ON_TRUE_RETURN_VAL(event->delete_me, NULL);
event->delete_me = 1;
data = event->data;
unlock:
_ecore_unlock();
return data;
return event->data;
}
EAPI int
ecore_event_type_new(void)
{
int id;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(0);
_ecore_lock();
id = event_id_max++;
_ecore_unlock();
return id;
return event_id_max++;
}
EAPI Ecore_Event_Filter *
@ -254,42 +216,33 @@ ecore_event_filter_add(Ecore_Data_Cb func_start,
Ecore_Event_Filter *ef = NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
if (!func_filter) goto unlock;
if (!func_filter) return NULL;
ef = ecore_event_filter_calloc(1);
if (!ef) goto unlock;
if (!ef) return NULL;
ECORE_MAGIC_SET(ef, ECORE_MAGIC_EVENT_FILTER);
ef->func_start = func_start;
ef->func_filter = func_filter;
ef->func_end = func_end;
ef->data = (void *)data;
event_filters = (Ecore_Event_Filter *)eina_inlist_append(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef));
unlock:
_ecore_unlock();
return ef;
}
EAPI void *
ecore_event_filter_del(Ecore_Event_Filter *ef)
{
void *data = NULL;
if (!ef) return NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
if (!ECORE_MAGIC_CHECK(ef, ECORE_MAGIC_EVENT_FILTER))
{
ECORE_MAGIC_FAIL(ef, ECORE_MAGIC_EVENT_FILTER, "ecore_event_filter_del");
goto unlock;
return NULL;
}
EINA_SAFETY_ON_TRUE_GOTO(ef->delete_me, unlock);
EINA_SAFETY_ON_TRUE_RETURN_VAL(ef->delete_me, NULL);
ef->delete_me = 1;
event_filters_delete_me = 1;
data = ef->data;
unlock:
_ecore_unlock();
return data;
return ef->data;
}
EAPI int

View File

@ -68,13 +68,9 @@ ecore_idle_enterer_add(Ecore_Task_Cb func,
EOLIAN static void
_ecore_idle_enterer_after_constructor(Eo *obj, Ecore_Idle_Enterer_Data *ie, Ecore_Task_Cb func, const void *data)
{
_ecore_lock();
if (!_ecore_idle_enterer_add(obj, ie, func, data)) goto unlock;
if (!_ecore_idle_enterer_add(obj, ie, func, data)) return;
idle_enterers = (Ecore_Idle_Enterer_Data *)eina_inlist_append(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
unlock:
_ecore_unlock();
}
EAPI Ecore_Idle_Enterer *
@ -89,27 +85,18 @@ ecore_idle_enterer_before_add(Ecore_Task_Cb func,
EOLIAN static void
_ecore_idle_enterer_before_constructor(Eo *obj, Ecore_Idle_Enterer_Data *ie, Ecore_Task_Cb func, const void *data)
{
_ecore_lock();
if (!_ecore_idle_enterer_add(obj, ie, func, data)) goto unlock;
if (!_ecore_idle_enterer_add(obj, ie, func, data)) return;
idle_enterers = (Ecore_Idle_Enterer_Data *)eina_inlist_prepend(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
unlock:
_ecore_unlock();
}
EAPI void *
ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer)
{
void *data = NULL;
if (!idle_enterer) return NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
data = _ecore_idle_enterer_del(idle_enterer);
_ecore_unlock();
return data;
return _ecore_idle_enterer_del(idle_enterer);
}
static void *

View File

@ -46,37 +46,28 @@ _ecore_idle_exiter_constructor(Eo *obj, Ecore_Idle_Exiter_Data *ie, Ecore_Task_C
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
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);
goto unlock;
return ;
}
ie->func = func;
ie->data = (void *)data;
idle_exiters = (Ecore_Idle_Exiter_Data *)eina_inlist_append(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie));
unlock:
_ecore_unlock();
}
EAPI void *
ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter)
{
void *data;
if (!idle_exiter) return NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
data = _ecore_idle_exiter_del(idle_exiter);
_ecore_unlock();
return data;
return _ecore_idle_exiter_del(idle_exiter);
}
static void *

View File

@ -35,14 +35,7 @@ EAPI Ecore_Idler *
ecore_idler_add(Ecore_Task_Cb func,
const void *data)
{
Ecore_Idler *ie = NULL;
_ecore_lock();
ie = eo_add(MY_CLASS, _ecore_parent, ecore_idler_constructor(func, data));
_ecore_unlock();
return ie;
return eo_add(MY_CLASS, _ecore_parent, ecore_idler_constructor(func, data));
}
EOLIAN static void
@ -70,15 +63,10 @@ _ecore_idler_constructor(Eo *obj, Ecore_Idler_Data *ie, Ecore_Task_Cb func, cons
EAPI void *
ecore_idler_del(Ecore_Idler *idler)
{
void *data = NULL;
if (!idler) return NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
data = _ecore_idler_del(idler);
_ecore_unlock();
return data;
return _ecore_idler_del(idler);
}
static void *

View File

@ -700,7 +700,6 @@ _ecore_main_gsource_prepare(GSource *source EINA_UNUSED,
{
gboolean ready = FALSE;
_ecore_lock();
in_main_loop++;
if (!ecore_idling && !_ecore_glib_idle_enterer_called)
@ -779,7 +778,6 @@ _ecore_main_gsource_prepare(GSource *source EINA_UNUSED,
in_main_loop--;
DBG("leave, timeout = %d", *next_time);
_ecore_unlock();
/* ready if we're not running (about to quit) */
return ready;
@ -790,7 +788,6 @@ _ecore_main_gsource_check(GSource *source EINA_UNUSED)
{
gboolean ret = FALSE;
_ecore_lock();
in_main_loop++;
/* check if old timers expired */
@ -830,7 +827,6 @@ _ecore_main_gsource_check(GSource *source EINA_UNUSED)
ret = (0.0 == _ecore_timer_next_get());
in_main_loop--;
_ecore_unlock();
return ret;
}
@ -844,7 +840,6 @@ _ecore_main_gsource_dispatch(GSource *source EINA_UNUSED,
gboolean events_ready, timers_ready, idlers_ready;
double next_time;
_ecore_lock();
_ecore_time_loop_time = ecore_time_get();
_ecore_timer_enable_new();
next_time = _ecore_timer_next_get();
@ -905,7 +900,6 @@ _ecore_main_gsource_dispatch(GSource *source EINA_UNUSED,
}
in_main_loop--;
_ecore_unlock();
return TRUE; /* what should be returned here? */
}
@ -1016,11 +1010,10 @@ _ecore_main_loop_uv_check(uv_check_t* handle EINA_UNUSED)
{
DBG("_ecore_main_loop_uv_check idling? %d", (int)_ecore_main_uv_idling);
in_main_loop++;
_ecore_lock();
if(do_quit)
goto quit;
do
{
_ecore_main_fd_handlers_call();
@ -1033,9 +1026,8 @@ _ecore_main_loop_uv_check(uv_check_t* handle EINA_UNUSED)
_ecore_timer_cleanup();
}
while(fd_handlers_to_call);
quit:
quit:
in_main_loop--;
_ecore_unlock();
}
#endif
@ -1233,10 +1225,8 @@ ecore_main_loop_iterate(void)
if(!_dl_uv_run) {
#endif
#ifndef USE_G_MAIN_LOOP
_ecore_lock();
_ecore_time_loop_time = ecore_time_get();
_ecore_main_loop_iterate_internal(1);
_ecore_unlock();
#else
g_main_context_iteration(NULL, 0);
#endif
@ -1255,12 +1245,10 @@ ecore_main_loop_iterate_may_block(int may_block)
if(!_dl_uv_run) {
#endif
#ifndef USE_G_MAIN_LOOP
_ecore_lock();
_ecore_time_loop_time = ecore_time_get();
in_main_loop++;
_ecore_main_loop_iterate_internal(!may_block);
in_main_loop--;
_ecore_unlock();
return _ecore_event_exist();
#else
return g_main_context_iteration(NULL, may_block);
@ -1291,13 +1279,11 @@ ecore_main_loop_begin(void)
if(!_dl_uv_run) {
#endif
#ifndef USE_G_MAIN_LOOP
_ecore_lock();
in_main_loop++;
_ecore_time_loop_time = ecore_time_get();
while (do_quit == 0) _ecore_main_loop_iterate_internal(0);
do_quit = 0;
in_main_loop--;
_ecore_unlock();
#else
if (!do_quit)
{
@ -1420,9 +1406,7 @@ ecore_main_fd_handler_add(int fd,
{
Ecore_Fd_Handler *fdh = NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
fdh = _ecore_main_fd_handler_add(fd, flags, func, data, buf_func, buf_data, EINA_FALSE);
_ecore_unlock();
return fdh;
}
@ -1434,13 +1418,8 @@ ecore_main_fd_handler_file_add(int fd,
Ecore_Fd_Cb buf_func,
const void *buf_data)
{
Ecore_Fd_Handler *fdh = NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
fdh = _ecore_main_fd_handler_add(fd, flags, func, data, buf_func, buf_data, EINA_TRUE);
_ecore_unlock();
return fdh;
return _ecore_main_fd_handler_add(fd, flags, func, data, buf_func, buf_data, EINA_TRUE);
}
#ifdef _WIN32
@ -1481,22 +1460,16 @@ ecore_main_win32_handler_add(void *h EINA_UNUSED,
EAPI void *
ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler)
{
void *ret = NULL;
if (!fd_handler) return NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
{
ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
"ecore_main_fd_handler_del");
goto unlock;
return NULL;
}
ret = _ecore_main_fd_handler_del(fd_handler);
unlock:
_ecore_unlock();
return ret;
return _ecore_main_fd_handler_del(fd_handler);
}
#ifdef _WIN32
@ -1546,13 +1519,12 @@ ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler,
const void *data)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
{
ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
"ecore_main_fd_handler_prepare_callback_set");
goto unlock;
return ;
}
fd_handler->prep_func = func;
fd_handler->prep_data = (void *)data;
@ -1560,28 +1532,20 @@ ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler,
(fd_handlers_with_prep && (!eina_list_data_find(fd_handlers_with_prep, fd_handler))))
/* FIXME: THIS WILL NOT SCALE WITH LOTS OF PREP FUNCTIONS!!! */
fd_handlers_with_prep = eina_list_append(fd_handlers_with_prep, fd_handler);
unlock:
_ecore_unlock();
}
EAPI int
ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler)
{
int fd = -1;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(-1);
_ecore_lock();
if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
{
ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
"ecore_main_fd_handler_fd_get");
goto unlock;
return -1;
}
fd = fd_handler->fd;
unlock:
_ecore_unlock();
return fd;
return fd_handler->fd;
}
EAPI Eina_Bool
@ -1591,19 +1555,16 @@ ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler,
int ret = EINA_FALSE;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(EINA_FALSE);
_ecore_lock();
if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
{
ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
"ecore_main_fd_handler_active_get");
goto unlock;
return EINA_FALSE;
}
if ((flags & ECORE_FD_READ) && (fd_handler->read_active)) ret = EINA_TRUE;
if ((flags & ECORE_FD_WRITE) && (fd_handler->write_active)) ret = EINA_TRUE;
if ((flags & ECORE_FD_ERROR) && (fd_handler->error_active)) ret = EINA_TRUE;
unlock:
_ecore_unlock();
return ret;
}
@ -1614,13 +1575,12 @@ ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler,
int ret;
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
{
ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
"ecore_main_fd_handler_active_set");
goto unlock;
return ;
}
fd_handler->flags = flags;
ret = _ecore_main_fdh_poll_modify(fd_handler);
@ -1628,8 +1588,6 @@ ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler,
{
ERR("Failed to mod epoll fd %d: %s!", fd_handler->fd, strerror(ret));
}
unlock:
_ecore_unlock();
}
void
@ -1804,11 +1762,9 @@ _ecore_main_select(double timeout)
}
if (_ecore_signal_count_get()) return -1;
_ecore_unlock();
eina_evlog("!SLEEP", NULL, 0.0, t ? "timeout" : "forever");
ret = main_loop_select(max_fd + 1, &rfds, &wfds, &exfds, t);
eina_evlog("!WAKE", NULL, 0.0, NULL);
_ecore_lock();
_ecore_time_loop_time = ecore_time_get();
if (ret < 0)
@ -2082,7 +2038,6 @@ _ecore_main_fd_handlers_buf_call(void)
static void
_ecore_main_loop_uv_prepare(uv_prepare_t* handle EINA_UNUSED)
{
_ecore_lock();
_dl_uv_timer_stop(&_ecore_main_uv_handle_timers);
if(in_main_loop == 0 && do_quit)
{
@ -2112,17 +2067,16 @@ _ecore_main_loop_uv_prepare(uv_prepare_t* handle EINA_UNUSED)
fd_handlers_to_call_current = NULL;
fd_handlers_to_delete = NULL;
fd_handler_current = NULL;
_dl_uv_prepare_stop(&_ecore_main_uv_prepare);
_dl_uv_check_stop(&_ecore_main_uv_check);
_dl_uv_stop(_dl_uv_default_loop());
_ecore_unlock();
return;
}
in_main_loop++;
if(!_ecore_main_uv_idling)
{
_ecore_main_uv_idling = EINA_TRUE;
@ -2147,7 +2101,7 @@ _ecore_main_loop_uv_prepare(uv_prepare_t* handle EINA_UNUSED)
{
_ecore_idle_exiter_call();
_ecore_animator_run_reset();
_ecore_main_uv_idling = EINA_FALSE;
}
@ -2185,7 +2139,6 @@ _ecore_main_loop_uv_prepare(uv_prepare_t* handle EINA_UNUSED)
if (fd_handlers_with_prep)
_ecore_main_prepare_handlers();
_ecore_unlock();
in_main_loop--;
}
#endif

View File

@ -108,9 +108,7 @@ ecore_pipe_add(Ecore_Pipe_Cb handler,
{
Ecore_Pipe *p;
_ecore_lock();
p = _ecore_pipe_add(handler, data);
_ecore_unlock();
return p;
}
@ -118,24 +116,19 @@ ecore_pipe_add(Ecore_Pipe_Cb handler,
EAPI void *
ecore_pipe_del(Ecore_Pipe *p)
{
void *r;
if (!p) return NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
r = _ecore_pipe_del(p);
_ecore_unlock();
return r;
return _ecore_pipe_del(p);
}
EAPI void
ecore_pipe_read_close(Ecore_Pipe *p)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
{
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_read_close");
goto out;
return ;
}
if (p->fd_handler)
{
@ -147,8 +140,6 @@ ecore_pipe_read_close(Ecore_Pipe *p)
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
}
out:
_ecore_unlock();
}
EAPI int
@ -162,30 +153,26 @@ EAPI void
ecore_pipe_freeze(Ecore_Pipe *p)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
{
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_read_freeze");
goto out;
return ;
}
if (p->fd_handler)
{
_ecore_main_fd_handler_del(p->fd_handler);
p->fd_handler = NULL;
}
out:
_ecore_unlock();
}
EAPI void
ecore_pipe_thaw(Ecore_Pipe *p)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
{
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_read_thaw");
goto out;
return ;
}
if (!p->fd_handler && p->fd_read != PIPE_FD_INVALID)
{
@ -195,8 +182,6 @@ ecore_pipe_thaw(Ecore_Pipe *p)
p,
NULL, NULL);
}
out:
_ecore_unlock();
}
EAPI int
@ -204,29 +189,22 @@ ecore_pipe_wait(Ecore_Pipe *p,
int message_count,
double wait)
{
int r;
_ecore_lock();
r = _ecore_pipe_wait(p, message_count, wait);
_ecore_unlock();
return r;
return _ecore_pipe_wait(p, message_count, wait);
}
EAPI void
ecore_pipe_write_close(Ecore_Pipe *p)
{
_ecore_lock();
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
{
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write_close");
goto out;
return ;
}
if (p->fd_write != PIPE_FD_INVALID)
{
pipe_close(p->fd_write);
p->fd_write = PIPE_FD_INVALID;
}
out:
_ecore_unlock();
}
EAPI int
@ -246,7 +224,6 @@ ecore_pipe_write(Ecore_Pipe *p,
int retry = ECORE_PIPE_WRITE_RETRY;
Eina_Bool ok = EINA_FALSE;
_ecore_lock();
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
{
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write");
@ -329,7 +306,6 @@ ecore_pipe_write(Ecore_Pipe *p,
while (retry--);
out:
_ecore_unlock();
return ok;
}
@ -529,9 +505,7 @@ _ecore_pipe_handler_call(Ecore_Pipe *p,
if (!p->delete_me)
{
_ecore_unlock();
p->handler(data, buf, len);
_ecore_lock();
}
// free p->passed_data

View File

@ -274,82 +274,19 @@ void _ecore_throttle(void);
void _ecore_main_call_flush(void);
extern int _ecore_main_lock_count;
extern Eina_Lock _ecore_main_loop_lock;
static inline void
_ecore_lock(void)
{
#ifdef HAVE_THREAD_SAFETY
/* THIS IS BROKEN AND NEEDS FIXING
*
* the concept of lock to execute main-loop related functions is okay
* and the code below is correct per se, but with its usage in Ecore
* is leading to hard locks that must be investigated.
*
* One failure possibility is missing _ecore_unlock() that leaves
* the lock taken and on next take it will block.
*
* Another failure possibility is one function that takes the lock
* and calls some API function that also takes the lock, leading to
* block.
*
* When these are fixed, remove the HAVE_THREAD_SAFETY and leave it
* always on. To eliminate the lock overhead for non-threaded
* applications, have a global boolean that is set to TRUE by user
* if he uses this features, much like eina_log_threads_enable().
* -- Gustavo, December 6th 2012.
*/
eina_lock_take(&_ecore_main_loop_lock);
#else
/* at least check we're not being called from a thread */
EINA_MAIN_LOOP_CHECK_RETURN;
#endif
_ecore_main_lock_count++;
/* assert(_ecore_main_lock_count == 1); */
}
static inline void
_ecore_unlock(void)
{
#ifndef HAVE_THREAD_SAFETY
/* see _ecore_lock(); no-op unless EINA_HAVE_DEBUG_THREADS is defined */
EINA_MAIN_LOOP_CHECK_RETURN;
#endif
_ecore_main_lock_count--;
/* assert(_ecore_main_lock_count == 0); */
#ifdef HAVE_THREAD_SAFETY
eina_lock_release(&_ecore_main_loop_lock);
#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;
return func(data);
}
static inline void *
_ecore_call_data_cb(Ecore_Data_Cb func,
void *data)
{
void *r;
_ecore_unlock();
r = func(data);
_ecore_lock();
return r;
return func(data);
}
static inline void
@ -357,9 +294,7 @@ _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
@ -369,13 +304,7 @@ _ecore_call_filter_cb(Ecore_Filter_Cb func,
int type,
void *event)
{
Eina_Bool r;
_ecore_unlock();
r = func(data, loop_data, type, event);
_ecore_lock();
return r;
return func(data, loop_data, type, event);
}
static inline Eina_Bool
@ -384,13 +313,7 @@ _ecore_call_handler_cb(Ecore_Event_Handler_Cb func,
int type,
void *event)
{
Eina_Bool r;
_ecore_unlock();
r = func(data, type, event);
_ecore_lock();
return r;
return func(data, type, event);
}
static inline void
@ -398,9 +321,7 @@ _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
@ -408,13 +329,7 @@ _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;
return func(data, fd_handler);
}
extern int _ecore_fps_debug;

View File

@ -251,10 +251,8 @@ _ecore_signal_call(void)
doomsday_clock = _ecore_exe_doomsday_clock_get(e->exe);
IF_FN_DEL(ecore_timer_del, doomsday_clock);
_ecore_unlock();
doomsday_clock = ecore_timer_add
(0.1, _ecore_signal_exe_exit_delay, e);
_ecore_lock();
_ecore_exe_doomsday_clock_set(e->exe, doomsday_clock);
}
else

View File

@ -76,17 +76,13 @@ EAPI void
ecore_timer_precision_set(double value)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
if (value < 0.0)
{
ERR("Precision %f less than zero, ignored", value);
goto unlock;
return ;
}
precision = value;
unlock:
_ecore_unlock();
}
EAPI Ecore_Timer *
@ -139,11 +135,9 @@ _ecore_timer_constructor(Eo *obj, Ecore_Timer_Data *timer, double in, Ecore_Task
{
double now;
_ecore_lock();
now = ecore_time_get();
_ecore_timer_add(obj, timer, now, in, func, data);
_ecore_unlock();
}
EOLIAN static void
@ -161,28 +155,16 @@ ecore_timer_loop_add(double in,
Ecore_Task_Cb func,
const void *data)
{
Ecore_Timer *timer;
_ecore_lock();
timer = _ecore_timer_loop_add(in, func, data);
_ecore_unlock();
return timer;
return _ecore_timer_loop_add(in, func, data);
}
EAPI void *
ecore_timer_del(Ecore_Timer *timer)
{
void *data = NULL;
if (!timer) return NULL;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
data = _ecore_timer_del(timer);
_ecore_unlock();
return data;
return _ecore_timer_del(timer);
}
EOLIAN static void
@ -191,9 +173,7 @@ _ecore_timer_interval_set(Eo *obj EINA_UNUSED, Ecore_Timer_Data *timer, double i
EINA_MAIN_LOOP_CHECK_RETURN;
if (in < 0.0) in = 0.0;
_ecore_lock();
timer->in = in;
_ecore_unlock();
}
EOLIAN static double
@ -202,9 +182,7 @@ _ecore_timer_interval_get(Eo *obj EINA_UNUSED, Ecore_Timer_Data *timer)
double ret = -1.0;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(ret);
_ecore_lock();
ret = timer->in;
_ecore_unlock();
return ret;
}
@ -214,9 +192,7 @@ _ecore_timer_delay(Eo *obj, Ecore_Timer_Data *_pd EINA_UNUSED, double add)
{
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
_ecore_timer_util_delay(obj, add);
_ecore_unlock();
}
EOLIAN static void
@ -225,7 +201,6 @@ _ecore_timer_reset(Eo *obj, Ecore_Timer_Data *timer)
double now, add;
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
now = ecore_time_get();
if (timer->frozen)
@ -233,7 +208,6 @@ _ecore_timer_reset(Eo *obj, Ecore_Timer_Data *timer)
else
add = timer->at - now;
_ecore_timer_util_delay(obj, timer->in - add);
_ecore_unlock();
}
EOLIAN static double
@ -244,15 +218,12 @@ _ecore_timer_pending_get(Eo *obj EINA_UNUSED, Ecore_Timer_Data *timer)
EINA_MAIN_LOOP_CHECK_RETURN_VAL(ret);
_ecore_lock();
now = ecore_time_get();
if (timer->frozen)
ret = timer->pending;
else
ret = timer->at - now;
_ecore_unlock();
return ret;
}
@ -271,11 +242,9 @@ _ecore_timer_eo_base_event_freeze(Eo *obj EINA_UNUSED, Ecore_Timer_Data *timer)
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
/* Timer already frozen */
if (timer->frozen)
goto unlock;
return;
timers = (Ecore_Timer_Data *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
suspended = (Ecore_Timer_Data *)eina_inlist_prepend(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
@ -285,8 +254,6 @@ _ecore_timer_eo_base_event_freeze(Eo *obj EINA_UNUSED, Ecore_Timer_Data *timer)
timer->pending = timer->at - now;
timer->at = 0.0;
timer->frozen = 1;
unlock:
_ecore_unlock();
}
EAPI Eina_Bool
@ -320,18 +287,14 @@ _ecore_timer_eo_base_event_thaw(Eo *obj, Ecore_Timer_Data *timer)
EINA_MAIN_LOOP_CHECK_RETURN;
_ecore_lock();
/* Timer not frozen */
if (!timer->frozen)
goto unlock;
return ;
suspended = (Ecore_Timer_Data *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
now = ecore_time_get();
_ecore_timer_set(obj, timer->pending + now, timer->in, timer->func, timer->data);
unlock:
_ecore_unlock();
}
EAPI char *
@ -346,7 +309,6 @@ ecore_timer_dump(void)
int unknow_timer = 0;
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
_ecore_lock();
result = eina_strbuf_new();
EINA_INLIST_FOREACH(timers, tm)
@ -382,7 +344,6 @@ ecore_timer_dump(void)
out = eina_strbuf_string_steal(result);
eina_strbuf_free(result);
_ecore_unlock();
return out;
#else
@ -678,7 +639,6 @@ _ecore_timer_reschedule(Ecore_Timer *obj,
_ecore_timer_set(obj, timer->at + timer->in, timer->in, timer->func, timer->data);
}
/* assume that we hold the ecore lock when entering this function */
void
_ecore_timer_expired_timers_call(double when)
{
@ -686,7 +646,6 @@ _ecore_timer_expired_timers_call(double when)
while (_ecore_timer_expired_call(when)) ;
}
/* assume that we hold the ecore lock when entering this function */
int
_ecore_timer_expired_call(double when)
{