Help: multithreaded GNOME app
- From: Miguel de Icaza <miguel nuclecu unam mx>
- To: Jason Tackaberry <tack dok org>
- Cc: gnome-list gnome org
- Subject: Help: multithreaded GNOME app
- Date: Mon, 1 Feb 1999 18:16:15 -0600 (CST)
>>>>> "Jason" == Jason Tackaberry <tack@dok.org> writes:
> So gtk_main() will be run by thread A, and thread A will be
> responsible for all GUI calls. So if thread B comes along and
> needs to make a gtk call, it can put this on some sort of queue.
Ok. this is very simple to do.
Create a pipe (using the pipe() system call) and monitor the read side
of the pipe on the GUI thread, like this:
int pipes [2];
pipe (pipes);
gdk_input_add (pipes [0], GDK_INPUT_READ, notify_function);
Then, on the thread that needs to notify the GUi, do this:
{
char c;
write (pipes [1], &c, sizeof (c));
}
Your notify_function will be invoked. Make sure you read one byte
every time. And of course, check the return values for read/write,
they might return -1/errno=EINTR, so you need to retry and stuff.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]