Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-02-25 12:39:06


Frank Mori Hess wrote:

> On Sunday 25 February 2007 12:07 pm, Peter Dimov wrote:
>
> > Now that I think about it, it can be implemented both ways. A slot that
> > requires an explicit lock() before operator() would still need the
> > .track. A slot that throws bad_weak_ptr from operator() would not. This
> > brings us back to the problem of autodisconnects only happening on
> > calls. :-/ It doesn't have to be either-or, though.
>
> Yes, I was assuming an explicit lock(), and perhaps exposing the tracked
> object list read-only for efficiency, which would allow multiple slots to
> be locked at once without creating a separate container for each slot.

I think I prefer:

bool expired() const;
R operator()( A... ) const; // throws bad_weak_ptr

operator() could do alloca() tricks to avoid dynamic allocations. The
portable version could use a local array< shared_ptr, K > to catch the
common case when the number of tracked objects is no more than K.

Hiding a slot behind a bind() or some other adaptor (std::not1, say) would
make it invisible to the expired() query, but it will still track its
objects within its operator().


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