emotion: lock pending events and pending objects
Summary: _emotion_pending_ecore_begin and _emotion_pending_ecore_end are not called from the same thread. Indeed, _emotion_pending_ecore_begin is called from gstreamer callbacks, and _emotion_pending_ecore_end is called from the mainloop. Reviewers: cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3061 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
64a7b3d44f
commit
eeba25397f
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
static Emotion_Version _version = { VMAJ, VMIN, VMIC, VREV };
|
static Emotion_Version _version = { VMAJ, VMIN, VMIC, VREV };
|
||||||
static int emotion_pending_objects = 0;
|
static int emotion_pending_objects = 0;
|
||||||
|
static Eina_Lock emotion_pending_lock;
|
||||||
EAPI Emotion_Version *emotion_version = &_version;
|
EAPI Emotion_Version *emotion_version = &_version;
|
||||||
|
|
||||||
Eina_Prefix *_emotion_pfx = NULL;
|
Eina_Prefix *_emotion_pfx = NULL;
|
||||||
|
@ -199,13 +200,17 @@ static int emotion_pendig_events = 0;
|
||||||
EAPI void
|
EAPI void
|
||||||
_emotion_pending_ecore_begin(void)
|
_emotion_pending_ecore_begin(void)
|
||||||
{
|
{
|
||||||
|
eina_lock_take(&emotion_pending_lock);
|
||||||
emotion_pendig_events++;
|
emotion_pendig_events++;
|
||||||
|
eina_lock_release(&emotion_pending_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
_emotion_pending_ecore_end(void)
|
_emotion_pending_ecore_end(void)
|
||||||
{
|
{
|
||||||
|
eina_lock_take(&emotion_pending_lock);
|
||||||
emotion_pendig_events--;
|
emotion_pendig_events--;
|
||||||
|
eina_lock_release(&emotion_pending_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
|
@ -220,11 +225,16 @@ emotion_shutdown(void)
|
||||||
}
|
}
|
||||||
if (--_emotion_init_count) return EINA_TRUE;
|
if (--_emotion_init_count) return EINA_TRUE;
|
||||||
|
|
||||||
|
eina_lock_take(&emotion_pending_lock);
|
||||||
start = ecore_time_get();
|
start = ecore_time_get();
|
||||||
while (((emotion_pending_objects > 0) ||
|
while (((emotion_pending_objects > 0) ||
|
||||||
(emotion_pendig_events > 0)) &&
|
(emotion_pendig_events > 0)) &&
|
||||||
((ecore_time_get() - start) < 0.5))
|
((ecore_time_get() - start) < 0.5))
|
||||||
ecore_main_loop_iterate();
|
{
|
||||||
|
eina_lock_release(&emotion_pending_lock);
|
||||||
|
ecore_main_loop_iterate();
|
||||||
|
eina_lock_take(&emotion_pending_lock);
|
||||||
|
}
|
||||||
|
|
||||||
if (emotion_pending_objects > 0)
|
if (emotion_pending_objects > 0)
|
||||||
{
|
{
|
||||||
|
@ -234,6 +244,9 @@ emotion_shutdown(void)
|
||||||
{
|
{
|
||||||
ERR("There is still %i Emotion events queued", emotion_pendig_events);
|
ERR("There is still %i Emotion events queued", emotion_pendig_events);
|
||||||
}
|
}
|
||||||
|
eina_lock_release(&emotion_pending_lock);
|
||||||
|
|
||||||
|
eina_lock_free(&emotion_pending_lock);
|
||||||
|
|
||||||
emotion_modules_shutdown();
|
emotion_modules_shutdown();
|
||||||
|
|
||||||
|
@ -263,11 +276,15 @@ emotion_shutdown(void)
|
||||||
EAPI void
|
EAPI void
|
||||||
_emotion_pending_object_ref(void)
|
_emotion_pending_object_ref(void)
|
||||||
{
|
{
|
||||||
|
eina_lock_take(&emotion_pending_lock);
|
||||||
emotion_pending_objects++;
|
emotion_pending_objects++;
|
||||||
|
eina_lock_release(&emotion_pending_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
_emotion_pending_object_unref(void)
|
_emotion_pending_object_unref(void)
|
||||||
{
|
{
|
||||||
|
eina_lock_take(&emotion_pending_lock);
|
||||||
emotion_pending_objects--;
|
emotion_pending_objects--;
|
||||||
|
eina_lock_release(&emotion_pending_lock);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue