aboutsummaryrefslogtreecommitdiffstats
path: root/legacy/ecore/src/lib/ecore/ecore.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2011-08-01 12:16:39 +0000
committerCedric BAIL <cedric.bail@free.fr>2011-08-01 12:16:39 +0000
commitd0e8b833a94a632c4c5e0345107550099ccb0fe7 (patch)
treed011f15103b7679ad385b0a3a77cf1d091a5b015 /legacy/ecore/src/lib/ecore/ecore.c
parentEvas textblock: Use the set language with liblinebreak if known. (diff)
downloadefl-d0e8b833a94a632c4c5e0345107550099ccb0fe7.tar.gz
ecore: merge call to main loop together to reduce number of main loop wakeup.
SVN revision: 61947
Diffstat (limited to 'legacy/ecore/src/lib/ecore/ecore.c')
-rw-r--r--legacy/ecore/src/lib/ecore/ecore.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/legacy/ecore/src/lib/ecore/ecore.c b/legacy/ecore/src/lib/ecore/ecore.c
index d4d2f739c4..a1d0d3cab8 100644
--- a/legacy/ecore/src/lib/ecore/ecore.c
+++ b/legacy/ecore/src/lib/ecore/ecore.c
@@ -61,6 +61,7 @@ struct _Ecore_Safe_Call
};
static void _thread_callback(void *data, void *buffer, unsigned int nbyte);
+static Eina_List *_thread_cb = NULL;
static Ecore_Pipe *_thread_call = NULL;
static Eina_Lock _thread_safety;
@@ -224,6 +225,8 @@ EAPI void
ecore_main_loop_thread_safe_call(Ecore_Cb callback, void *data)
{
Ecore_Safe_Call *order;
+ int wakeup = 42;
+ Eina_Bool count;
if (eina_main_loop_is())
{
@@ -238,7 +241,11 @@ ecore_main_loop_thread_safe_call(Ecore_Cb callback, void *data)
order->data = data;
eina_lock_take(&_thread_safety);
- ecore_pipe_write(_thread_call, &order, sizeof (Ecore_Safe_Call*));
+
+ count = _thread_cb ? 0 : 1;
+ _thread_cb = eina_list_append(_thread_cb, order);
+ if (count) ecore_pipe_write(_thread_call, &wakeup, sizeof (int));
+
eina_lock_release(&_thread_safety);
}
@@ -469,16 +476,21 @@ _ecore_memory_statistic(__UNUSED__ void *data)
#endif
static void
-_thread_callback(void *data __UNUSED__, void *buffer, unsigned int nbyte)
+_thread_callback(void *data __UNUSED__,
+ void *buffer __UNUSED__,
+ unsigned int nbyte __UNUSED__)
{
- Ecore_Safe_Call *call = buffer;
+ Ecore_Safe_Call *call;
+ Eina_List *callback;
+
+ eina_lock_take(&_thread_safety);
+ callback = _thread_cb;
+ _thread_cb = NULL;
+ eina_lock_release(&_thread_safety);
- while (nbyte >= sizeof (Ecore_Safe_Call*))
+ EINA_LIST_FREE(callback, call)
{
call->cb(call->data);
free(call);
-
- call++;
- nbyte -= sizeof (Ecore_Safe_Call*);
}
}