Re: Threads and gtkmm



Thanks Chris !

Yann Leydier<yann leydier info>  wrote:
Thanks for the info. I was still using g_idle_connect with static
methods to communicate between threads…

I assume you mean g_idle_add(), and that's a perfectly good way to do
it, and is thread safe, but you forfeit trackability.  (Although if you
are passing static class member functions to the callback argument of
g_idle_add() you technically have undefined behaviour because static
member functions have C++ linkage specification and not C linkage.
However, it will work OK with gcc, and glibmm does it, so you are not
adding any greater unportability.)

Yeah, sorry, I mistyped the name !

It works with GCC and seems to work also as well with Visual Studio 2008.

The first won't work because Dispatchers can't be copied (this is a
feature not a bug).  The second is not desirable because passing around
Dispatchers by pointer is likely to leave your code with dangling
pointers.
If a Dispatcher is a class member, why not provide an accessor
function, or make it a public member?  These would be the normal ways of
doing it (as with sigc::signal objects).

I'd rather not use an accessor to improve genericity of the object recieving the Dispatcher. I think I'll use shared (and perhaps weak) pointers.

yann


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