};
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;
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())
{
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);
}
#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*);
}
}