On Sat, Aug 07, 2004 at 12:49:35AM +0200, Soeren Sandmann wrote: > Daniel Nilsson <daniel@xxxxxxxxxxxxxxx> writes: > > > Any thoughts of a easier way to do this ? Could I use the glib > > GIOChannel somehow or coud the glib Asynchronous Queues help in any > > way ? > > Since you can select() on the serial port, you can avoid threads by > having a function called every time something interesting happens on > the file descriptor. The GLib mainloop has the functionality for this, > but I wouldn't suggest using the GIOChannel; I think they are way too > complex. Thanks to everyone who responded to my question, I understand that it's difficult to understand all the requirement when you haven't seen the program... I think what I'm hearing is basically the same idea from several people, separate out the GUI thread from the worker thread and use some synchronization mechanism (async queues for example) between the actual worker and the GUI. Unfortunately I wasn't expecting the communication portion of my program to have to block for such long periods of time so I didn't do a great job of separating GUI and workers in the beginning of my project. I'll know better next time... I prototyped a solution to the problem last night though which seems to work, I created another serial communication thread which runs every 100mS using g_timeout_add. This thread checks an incoming queue a (GQueue) for request and spawns of a background thread that runs and completes the request, using GQueue for the incoming requests works fine as far as I can tell since none of the functions run with g_timeout_add runs concurently anyway and all the incoming requests will come from such functions. When the background thread is done, the results are pushed onto an async queue and then error checked and moved to the final destination pointer. The requesting state machine will only see a NULL pointer for the result until an error free answer to the communition request is available. Seems to work fine in my limited testing so far. Thanks Daniel _______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list