On Thu, 08 Jul 2004 21:47:41 +0400, Dmitry M. Shatrov <zzidre@xxxxxxx> wrote: > Ok, gdk_threads_enter/leave is the way, but before coding it I'd like to > figure out if this could be done in a message-oriented manner, > not in cross-locking one. My app does this with pipes. I have a GUI thread and a pool of worker threads producing (in my case) pixel data. As the workers produce data, it gets painted asynchronously to the screen. I don't use the threads enter/leave stuff (it's much too annoying and fragile, in my opinion). Instead I have all gtk stuff in the main GUI thread and have a pipe which workers can post pointers down. The GUI thread uses gtk_input_add() so that it gets woken up when data arrives from the pipe. worker: - down() on semaphore for this thread - do some work, generating a struct of data - write pointer to struct to a pipe - loop GUI: - callback triggered when a pointer arrives down the pipe - read struct of data and paint screen (struct includes link to thread that made it) - up() on semaphore for thread to restart it Very simple and easy to program. I'm assuming writing 4 bytes to a pipe is atomic, I guess. I've not had problems (even on SMP machines), but it would be easy to add a global mutex for the pipe writers. John _______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list