Re: IPC with Gtk+
- From: Tristan Van Berkom <tristan van berkom gmail com>
- To: "Faria, Sydney C" <sydney faria pw utc com>
- Cc: "'gtk-list gnome org'" <gtk-list gnome org>
- Subject: Re: IPC with Gtk+
- Date: Fri, 22 Jul 2005 16:36:02 -0400
Faria, Sydney C wrote:
I am currently working on a few ideas that will enable me to communicate
with dual port memory using an SBS616 VME to PCI adapter card. The Gtk GUI
part is done and I am now working on the interprocess communication
necessary to use the dual port memory. My first attempt will be to run a
thread that is started before gtk_main() and after all the GUI widgets have
been constructed. All the label widgets that will display data via
label_set_text() will have arrays of pointers to the label widgets so that
the dualport thread can update these "data" labels. I don't think adding a
timer to do the updating is a good idea since I will have no control or
resource access as I would using mutex and condition variables. If anyone
has any feedback on this subject of IPC with gtk and another thread similar
to what I am doing please feel free to put forth any ideas -- any feedback
is better than none.
Hi,
Depending on your IPC needs you could (ofcourse) go about it in different
ways; If you only need to communicate data from child threads to the main thread
the easyest thing to do is just g_idle_add() (in conjunction with a GAsyncQueue),
this will always queue an idle event to the main context in a thread safe fashion.
If you need communiacation across all threads, then you'll have to make them sleep
on file descriptors when they are not busy (or this would be an efficient way).
I havent experimented with multiple GMainContext's but in theory it should work,
you should be able to run a mainloop with its own GMainContext in its own thread;
you'd just have to use the basic varients of GSources (i.e. instead of using
g_timout_add/g_io_add_watch; you'd use g_timeout_source_new ... g_source_attatch etc).
Personally I've always achieved this by hand; in other words only my main thread
runs a GMainLoop and I might have a worker thread which will implement its own
loop and sleep in poll() waiting for commands through a pipe() for example.
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]