summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib/ecore/ecore.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-08-13 08:52:45 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-08-13 08:52:45 +0000
commitfe00bc661a5986a11d2ff2faad75fcb35b6bc1b7 (patch)
tree9171c26f0255000fe15358aac00937aa5d8a95e7 /legacy/ecore/src/lib/ecore/ecore.c
parentb51f30b0828da23cc5fa2c4bba96fd5dfe2e49b1 (diff)
extend ecore fork infra to handle pipe re-create afetr fork for
ecore-evas. SVN revision: 75194
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/ecore/ecore.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/legacy/ecore/src/lib/ecore/ecore.c b/legacy/ecore/src/lib/ecore/ecore.c
index d8dc359bfc..0df319b593 100644
--- a/legacy/ecore/src/lib/ecore/ecore.c
+++ b/legacy/ecore/src/lib/ecore/ecore.c
@@ -305,9 +305,60 @@ unlock:
305 return _ecore_init_count; 305 return _ecore_init_count;
306} 306}
307 307
308struct _Ecore_Fork_Cb
309{
310 Ecore_Cb func;
311 void *data;
312 Eina_Bool delete_me : 1;
313};
314
315typedef struct _Ecore_Fork_Cb Ecore_Fork_Cb;
316
317static int fork_cbs_walking = 0;
318static Eina_List *fork_cbs = NULL;
319
320EAPI Eina_Bool
321ecore_fork_reset_callback_add(Ecore_Cb func, const void *data)
322{
323 Ecore_Fork_Cb *fcb;
324
325 fcb = calloc(1, sizeof(Ecore_Fork_Cb));
326 if (!fcb) return EINA_FALSE;
327 fcb->func = func;
328 fcb->data = (void *)data;
329 fork_cbs = eina_list_append(fork_cbs, fcb);
330 return EINA_TRUE;
331}
332
333EAPI Eina_Bool
334ecore_fork_reset_callback_del(Ecore_Cb func, const void *data)
335{
336 Eina_List *l;
337 Ecore_Fork_Cb *fcb;
338
339 EINA_LIST_FOREACH(fork_cbs, l, fcb)
340 {
341 if ((fcb->func == func) && (fcb->data == data))
342 {
343 if (!fork_cbs_walking)
344 {
345 fork_cbs = eina_list_remove_list(fork_cbs, l);
346 free(fcb);
347 }
348 else
349 fcb->delete_me = EINA_TRUE;
350 return EINA_TRUE;
351 }
352 }
353 return EINA_FALSE;
354}
355
308EAPI void 356EAPI void
309ecore_fork_reset(void) 357ecore_fork_reset(void)
310{ 358{
359 Eina_List *l, *ln;
360 Ecore_Fork_Cb *fcb;
361
311 eina_lock_take(&_thread_safety); 362 eina_lock_take(&_thread_safety);
312 363
313 ecore_pipe_del(_thread_call); 364 ecore_pipe_del(_thread_call);
@@ -316,6 +367,24 @@ ecore_fork_reset(void)
316 if (_thread_cb) ecore_pipe_write(_thread_call, &wakeup, sizeof (int)); 367 if (_thread_cb) ecore_pipe_write(_thread_call, &wakeup, sizeof (int));
317 368
318 eina_lock_release(&_thread_safety); 369 eina_lock_release(&_thread_safety);
370
371 // should this be done withing the eina lock stuff?
372
373 fork_cbs_walking++;
374 EINA_LIST_FOREACH(fork_cbs, l, fcb)
375 {
376 fcb->func(fcb->data);
377 }
378 fork_cbs_walking--;
379
380 EINA_LIST_FOREACH_SAFE(fork_cbs, l, ln, fcb)
381 {
382 if (fcb->delete_me)
383 {
384 fork_cbs = eina_list_remove_list(fork_cbs, l);
385 free(fcb);
386 }
387 }
319} 388}
320 389
321/** 390/**