summaryrefslogtreecommitdiff
path: root/src/lib/emotion
diff options
context:
space:
mode:
authorThomas Guillem <thomas@gllm.fr>2015-09-21 23:24:18 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-09-21 23:24:30 +0200
commiteeba25397f07ea044a1c4011b5c8dfcd46ccf0ea (patch)
tree7e889d85855ff2d438baf21364e7a55bcca5104b /src/lib/emotion
parent64a7b3d44f3f5d917943ac22c3af1221f1df7fdf (diff)
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>
Diffstat (limited to 'src/lib/emotion')
-rw-r--r--src/lib/emotion/emotion_main.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/emotion/emotion_main.c b/src/lib/emotion/emotion_main.c
index f8273908fe..d641621105 100644
--- a/src/lib/emotion/emotion_main.c
+++ b/src/lib/emotion/emotion_main.c
@@ -19,6 +19,7 @@
19 19
20static Emotion_Version _version = { VMAJ, VMIN, VMIC, VREV }; 20static Emotion_Version _version = { VMAJ, VMIN, VMIC, VREV };
21static int emotion_pending_objects = 0; 21static int emotion_pending_objects = 0;
22static Eina_Lock emotion_pending_lock;
22EAPI Emotion_Version *emotion_version = &_version; 23EAPI Emotion_Version *emotion_version = &_version;
23 24
24Eina_Prefix *_emotion_pfx = NULL; 25Eina_Prefix *_emotion_pfx = NULL;
@@ -199,13 +200,17 @@ static int emotion_pendig_events = 0;
199EAPI void 200EAPI void
200_emotion_pending_ecore_begin(void) 201_emotion_pending_ecore_begin(void)
201{ 202{
203 eina_lock_take(&emotion_pending_lock);
202 emotion_pendig_events++; 204 emotion_pendig_events++;
205 eina_lock_release(&emotion_pending_lock);
203} 206}
204 207
205EAPI void 208EAPI void
206_emotion_pending_ecore_end(void) 209_emotion_pending_ecore_end(void)
207{ 210{
211 eina_lock_take(&emotion_pending_lock);
208 emotion_pendig_events--; 212 emotion_pendig_events--;
213 eina_lock_release(&emotion_pending_lock);
209} 214}
210 215
211EAPI Eina_Bool 216EAPI Eina_Bool
@@ -220,11 +225,16 @@ emotion_shutdown(void)
220 } 225 }
221 if (--_emotion_init_count) return EINA_TRUE; 226 if (--_emotion_init_count) return EINA_TRUE;
222 227
228 eina_lock_take(&emotion_pending_lock);
223 start = ecore_time_get(); 229 start = ecore_time_get();
224 while (((emotion_pending_objects > 0) || 230 while (((emotion_pending_objects > 0) ||
225 (emotion_pendig_events > 0)) && 231 (emotion_pendig_events > 0)) &&
226 ((ecore_time_get() - start) < 0.5)) 232 ((ecore_time_get() - start) < 0.5))
227 ecore_main_loop_iterate(); 233 {
234 eina_lock_release(&emotion_pending_lock);
235 ecore_main_loop_iterate();
236 eina_lock_take(&emotion_pending_lock);
237 }
228 238
229 if (emotion_pending_objects > 0) 239 if (emotion_pending_objects > 0)
230 { 240 {
@@ -234,6 +244,9 @@ emotion_shutdown(void)
234 { 244 {
235 ERR("There is still %i Emotion events queued", emotion_pendig_events); 245 ERR("There is still %i Emotion events queued", emotion_pendig_events);
236 } 246 }
247 eina_lock_release(&emotion_pending_lock);
248
249 eina_lock_free(&emotion_pending_lock);
237 250
238 emotion_modules_shutdown(); 251 emotion_modules_shutdown();
239 252
@@ -263,11 +276,15 @@ emotion_shutdown(void)
263EAPI void 276EAPI void
264_emotion_pending_object_ref(void) 277_emotion_pending_object_ref(void)
265{ 278{
279 eina_lock_take(&emotion_pending_lock);
266 emotion_pending_objects++; 280 emotion_pending_objects++;
281 eina_lock_release(&emotion_pending_lock);
267} 282}
268 283
269EAPI void 284EAPI void
270_emotion_pending_object_unref(void) 285_emotion_pending_object_unref(void)
271{ 286{
287 eina_lock_take(&emotion_pending_lock);
272 emotion_pending_objects--; 288 emotion_pending_objects--;
289 eina_lock_release(&emotion_pending_lock);
273} 290}