Re: Help: multithreaded GNOME app
- From: Jeff Garzik <jgarzik pobox com>
- To: Jason Tackaberry <tack dok org>
- cc: Sri Ramkrishna <sri aracnet com>, gnome-list gnome org
- Subject: Re: Help: multithreaded GNOME app
- Date: Mon, 1 Feb 1999 16:39:18 -0500 (EST)
On Mon, 1 Feb 1999, Jason Tackaberry wrote:
> > Set up a pipe(), and pass one of the fds as an input source to Gtk+.
> > Gtk+ will then call your callback function whenever data arrives over
> > the pipe.
> That was my original thought, but I was wondering if there was a better
> approach to this. Except, how do I allocate the file descriptors? I'm
> assuming I can't just pick some arbitrary number > 2.
?? man pipe. It allocates two descriptors for you, one read, and one
write. If you want bi-directional communication, create two pipes.
I use pipes in all my multithreaded programs, mainly because select() is
the most convenient way to wait for an application event; and since Gtk+
provides a nice and easy-to-use event multiplexor system.
For speed, you only want to send read or write a single byte to the
pipe. This is sufficient to wake up the process. Do not use the pipe
to pass data larger than sizeof(void*) to the main process, doing so is
very wasteful.
Jeff
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]