Re: Removing widgets in the main loop from another thread



On Thu, 14 May 2009 11:17:52 -0400
Damon Register <damon w register lmco com> wrote:
> I am working on a small test app in order to understand how to use
> Glib::Thread.  I have read the Glib::Thread reference at
> http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1Thread.html
> and have also found a few gtkmm-list discussions such as this one.
> The problem is that I am still struggling to understand the issue with
> sigc::trackable not being thread safe.
> 
> In this example at
> http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/thread_2thread_8cc-example.html
> I see that MessageQueue is derived from sigc::trackable.  This
> appears to be a violation of what the class ref says
> 
>     Because sigc::trackable is not thread safe, if the slot
> represents a non-static class method (that is, it is created by
> sigc::mem_fun()), the class concerned should not derive from
> sigc::trackable.
> 
> Is the example program thread safe?  If it is thread safe, how is this
> not a violation of what the class ref says?  How would I change it
> to be unsafe?  Certainly I don't want to do that but I want to
> understand what not to do.
> 
> If the example is not thread safe, how would it be change to be safe?

No, it's not thread safe.  To make the example thread safe, I should
just not derive from sigc::trackable.  It isn't necessary for the
example to work (the MessageQueue object exists throughout program
execution). I suggest you then enter a bug for the example, with a
patch.

Chris



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