Re: Threading Problem
- From: Chris Vine <chris cvine freeserve co uk>
- To: Pavel Rojtberg <pavel madman2k net>
- Cc: gtkmm-list gnome org
- Subject: Re: Threading Problem
- Date: Wed, 27 Sep 2006 20:49:00 +0100
On Wednesday 27 September 2006 20:44, Chris Vine wrote:
> Both Glib::Dispatcher and Glib::SignalIdle should work similarly.
> Glib::Dispatcher uses a pipe under the covers, as does Glib::SignalIdle
> when used with Unix-like systems, although with different priorities in the
> main program loop, which will probably not make any difference in practice.
> I do not know if Glib::Dispatcher works with windows if you are interested
> in portablility, although Glib::SignalIdle does. The important thing with
> Glib::SignalIdle is to remember to have the handler return false.
> Returning true can turn your main loop into a busy wait.
And I should add that this leads to the main difference in practice - with
Glib::Dispatcher you connect the slot once and can execute it any time by
calling emit() on the dispatcher object (it operates as a thread safe
signal). With Glib::SignalIdle it fires once (the handler must return false)
so you have to reconnect the slot everytime you want it to execute.
This also means in practice that with Glib::Dispatcher it naturally leads to
passing arguments in queues or similar mechanisms, rather than trying to bind
to the slot.
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]