|
Boost Users : |
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2007-02-23 12:52:23
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday 23 February 2007 12:22 pm, Peter Dimov wrote:
>
> I actually like the suggestion of just offering a way to add the tracked
> pointers manually. Either
>
> sig.connect( boost::bind( myfunction, boost::ref(coord->x) ), coord );
>
> or
>
> sig.connect( boost::bind( myfunction, boost::ref(coord->x) ).track(
> coord );
>
> Both look better on a syntactic level to me. In addition, I suspect that
> signalslib::track contains a race condition that is avoided by the other
> alternatives (but I haven't actually looked at it so I might be wrong;
> it's possible, if somewhat tedious, to implement it correctly).
Would you elaborate on the race you are thinking of? Putting track in the
connection class instead of the slot class makes races possible, since the
connection is established before the tracked objects are added.
Admittedly, this is only a problem if you are holding the tracked objects
as weak_ptrs before giving them to the signal. In the slot it would be
more verbose:
signal_type::slot_type slot = boost::bind(&myfunction,
boost::ref(coord->x));
slot.track(coord);
sig.connect(slot);
- --
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFF3ynY5vihyNWuA4URArIeAKDZ0snLJb4GdOnPMr4m+Si9t1wbkgCcCM2k
YnbSJgwGIV/tvRxs5iHhxzQ=
=O3PN
-----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