Boost logo

Boost Users :

From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2007-02-02 16:38:52


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 02 February 2007 06:34 am, Timmo Stange wrote:
> The wrapper signals::track would expect a shared_ptr and transport
> a weak_ptr. The information could be collected with visit_each just
> like it is done now and the number of trackable objects would only
> be limited by boost::bind.

Okay, I think I've got it now. The signals::track() wrapper would return
some class, call it signals::tracked for now, which is implicitly
convertible into a weak_ptr. The code in signal::connect() would use
visit_each on the return value from bind to look for any signals::tracked
objects inside, and if found store them as weak_ptrs associated with the
connection. Then any slots with expired weak_ptrs could be cleaned up
when the signal is next emitted, or also in signal::connect() to prevent
lots of dead connections from accumulating. If we do cleanup in
connect(), then I could get rid of the disconnect callback stuff I added,
since it would be mostly redundant.

> I think it is acceptable that the client
> code must maintain a shared_ptr to the tracked instance, as that's
> expressing rather well what is happening here (even though it
> doesn't really share the ownership, it shares information about the
> object).

It does share ownership, at least during the periods when the signal is
actually running the slot.

- --
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFw69s5vihyNWuA4URAsgsAJwJ/lK1CGjV5ztNr4UD9QVDCU9pTwCbBIVg
6LivJe+uFrX7cOhhigkUnmM=
=wmTb
-----END PGP SIGNATURE-----


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