Hello, I had to change my edje GUI from a thread. After some help here I found a way to do that with pipes. I've created some helper functions to easy dispatch an GUI update from a thread. Perhaps it's usefull for anyone. Maybe this functions or anything similar could be inserted in ecore for easier use in threads.
ecore_dispatcher.c: #include "ecore_dispatcher.h" void dispatcher_init (Dispatcher *dp, int (dispatcher_async_handler) (void *data, Ecore_Fd_Handler *fdh)) { int fd[2]; Ecore_Fd_Handler *fd_handler; /* Create the file descriptors */ if (pipe(fd) == 0) { dp->fd_read = fd[0]; dp->fd_write = fd[1]; fcntl(dp->fd_read, F_SETFL, O_NONBLOCK); fd_handler = ecore_main_fd_handler_add (dp->fd_read, ECORE_FD_READ, dispatcher_async_handler, dp, NULL, NULL); ecore_main_fd_handler_active_set(fd_handler, ECORE_FD_READ); } else { fprintf (stderr, "pipe() failed\n"); exit (1); } } void dispatcher_signal (Dispatcher *dp) { write(dp->fd_write, "1", 2); } ecore_dispatcher.h: #ifndef ECORE_DISPATCHER #define ECORE_DISPATCHER #include <Ecore.h> #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> struct _Dispatcher { int fd_read; int fd_write; }; typedef struct _Dispatcher Dispatcher; void dispatcher_init (Dispatcher *dp, int (dispatcher_async_handler) (void *data, Ecore_Fd_Handler *fdh)); void dispatcher_signal (Dispatcher *dp); #endif // ECORE_DISPATCHER Here is how I use it: Dispatcher dp; int main () { dispatcher_init (&dp, dispatcher_async_handler); ... return 1; } // this is my thread.... thread_func () { ... dispatcher_signal (&dp); ... } int dispatcher_async_handler (void *data, Ecore_Fd_Handler *fdh) { int fd; char buf[1]; char edje_signal_local[sizeof (edje_signal)]; Dispatcher *dp_local; printf ("asynchronous data arrived\n"); dp_local = data; fd = ecore_main_fd_handler_fd_get(fdh); // reads all events and use only one while (read (fd, buf, sizeof (buf)) > 0); pthread_mutex_lock (&gps_mutex); strncpy (edje_signal_local, edje_signal, sizeof (edje_signal)); pthread_mutex_unlock (&gps_mutex); edje_object_signal_emit (o_edje, edje_signal_local, "degree"); return 1; } What do you think? Any comments? regards Andreas ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel