Boost logo

Boost Users :

From: Igor R (boost.lists_at_[hidden])
Date: 2008-07-22 11:57:45


...by the way, in the document of the thread_safe_signals the
following example appears:

// ...
boost::shared_ptr<NewsMessageArea> newsMessageArea(new
NewsMessageArea(/* ... */));
// ...
deliverNews.connect(signal_type::slot_type(&NewsMessageArea::displayNews,
  newsMessageArea, _1).track(newsMessageArea));

I.e., the slot is both tracked *and* bound as shared_ptr.
But if it's bound as a shared_ptr, it will never expire, so the
tracking is useless here, isn't it? Or am I miss something?

Thanks,

Igor'.

2008/7/22, Igor R <boost.lists_at_[hidden]>:
> Oh, I see that thread_safe_signals already does what I need - one can
> safely bind a regular pointer instead of shared_ptr (by the way, is it
> safe to do this if the object already inherits from
> enable_shared_from_this?).
> Is it planned to be released as a part of 1.36?
>
>
> > o1->someSignal_->connect(bind(&Class2::responder, o2)); // besides, o2
> > has a shared_ptr to o1
> >
> > I'd like this signal-slot to be "weak", i.e. instead of
> > "bind(&Class2::responder, o2)" I wish it could be
> > "bind(&Class2::responder, weak_ptr(o2))" - which is illegal.
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net