(not subscribed; please CC replies)
I'm trying to find a way to provide my mainloop with asynchronous data
from a thread. I have read this:
http://mail.gnome.org/archives/gtk-app-devel-list/2004-July/msg00181.html
which describes how to use a GAsyncQueue and GSource to watch the queue
for available data (and to have the thread wake up the mainloop when data
is available). A callback is run in the context of gtk_main when
data is available. It works perfectly except for one show-stopper
problem:
The GSourceFuncs prepare and check are only passed the GSource and
no other data. Thus, the only way they can check any variable is
through a global variable. Now, my program would like to dynamically
create several (likely never more than 3-5) threads to feed the
mainloop.
So, I see my options as: 1) hardcode several global queues (say 10 of
them) with seperate GSourceFuncs definitions (again, 10 of them) like
this:
static GAsyncQueue *queue_1;
static GSourceFuncs funcs_1 { prepare_1, check_1, dispatch_1, NULL };
static GAsyncQueue *queue_2;
static GSourceFuncs funcs_2 { prepare_2, check_2, dispatch_2, NULL };
... and so on
which is inelegant at best, and 2) feed everything through the single
global queue but wrap the data before pushing to the queue in a
structure with sufficient information to route the data to the
appropriate location. This may have some issues with the callback
spending too much time in the case of several threads pushing data at
once, but should be workable.
I suppose I will implement option 2, but I was wondering what other
options exist and what you think of this? Thank you.
(not subscribed; please CC replies)
--
Pat Mahoney [EMAIL PROTECTED]
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list