Re: Sending slots to main thread (implemented)




On Sat Sep  1 14:38 , Chris Vine  sent:

>On Thu, 2007-08-30 at 21:06 +0100, Chris Vine wrote:
>
>> In any event, if you do want to pass an entire slot to the queue, I
>> suspect it would be more efficient to have a pointer to a slot (or
>> shared_ptr >) as the contained element -
>> boost::shared_ptr for example has a thread-safe reference count. (I
>> don't know how much is involved in copying slots by value and whether
>> this would in fact comprise a performance advantage for this usage.)

An smart pointer is not needed. An slot is a very small structure thats stores a pointer to a 
dynamic allocated one that stores the parameters with the function pointer.

(I haven't take a look to sigc++ library but I think that it is implemented in this way)

To avoid the inclussion of many unrelated stuff in this e-amil, I hope next monday to answer 
your previous e-mail (it is on my working computer). Sorry for the delay.


>This reminds me that message passing to the main program thread in GTK+
>is normally done using g_idle_add() (which is thread safe) and there was
>a proposal to make the Glib::SignalIdle::connect() wrapper thread safe
>with a new Glib::SignalIdle::connect_once() function.  I don't know if
>Daniel has got anywhere with that 
>http://mail.gnome.org/archives/gtkmm-list/2007-January/msg00051.html
>
>You can however use the unwrapped g_idle_add() for passing your
>callbacks to the thread in which the default programme GMainContext is
>running, if you want.
>

Thanks but I think that my proposed class is working fine.

Note on Dispatcher class, I've taken a closer look to its interface. I've seen that the 
connect member function returns a sigc::connection object. this means that the signal could be 
disconnected from dispatcher and another one be connected.

(not tested)
sigc::conecttion connect = dispatcher.connect(sigc::mem_func(*this, example::func1param, 
"param1"));
dispatcher.emit();
connect.disconnect();
sigc::conecttion connect = dispatcher.connect(sigc::mem_func(*this, example::secondfunction, 
"second parameter"));
dispatcher.emit();

Thanks and Best Regards,
Joaquim Duran




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