Re: [gtkmm] Using threads ...



Hi!

andre-junior wrote:
I'd like to known if i need to use
Glib::Dispatcher all the time i need
to change something in screen

Strictly speaking, no. You can also use gdk_threads_enter() / gdk_threads_leave() to ensure that all calls to GTK are serialized. In practice, though, you'd probably be better off using Glib::Dispatcher or a similar mechanism.

and if
so, how can i wait for something
happen (the dispatcher notification
happens asynchronously).

You should check out libSigCX (http://libsigcx.sourceforge.net/). Although a little hard to grasp at first, it has great capabilities for cross-thread signalling (including synchronous signals).

The biggest
problem is that in this system there
is only on service to show a
"messagedialog" for example, and all
the threads call this service to show
the dialog, and either the main thread
or the other threads can call this
function.


Perhaps you should revisit your design? Most well-designed apps separate presentation from application logic in an MVC pattern or similar. In that case your application logic would never call GTK+ functions directly, but rather provide a mechanism for the presentation logic (i.e. the View) to get notified about changes that would (potentially) change the View. If you use libSigCX thread-tunneled signals for that mechanism, you'd easily be able to put all GTK stuff in a single View thread almost transparantly.

--
Christer Palm




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]