Christer Palm wrote:
John Cupitt wrote:

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.


Oh, by the way. On a POSIX conformant system, a write to a pipe _is_ guaranteed to be atomic as long as it's no larger than PIPE_BUF (from limits.h) bytes. So 4 bytes should be safe.

Just to point out one of the million possible solutions to this age old problem ('cause I liked this solution alot when I heard of it, I have to admit I haven't had the oportunity to try it myself since), you can create your own GSource that pops off elements from a GAsyncQueue and use that "source" in your recieving thread and in your publishing thread you can push datum on to that queue and call `g_main_context_wakeup()' on the recieving thread's context (ofcourse you can wrap that up in a pretty little convinient api...).

    I'm not sure exactly how much you gain in performance by using this
aproach, but I always though that using pipes to communicate between
threads is a kind of hack.

Cheers,
                                   -Tristan


_______________________________________________ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to