Boost Users :
Subject: Re: [Boost-users] [boost-users][signals2] thread-safe disconnection for intrusively ref-counted objects
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-05-12 15:07:40
-----BEGIN PGP SIGNED MESSAGE-----
On Tuesday 12 May 2009, Igor R wrote:
> // pseudo-code!
> class intrusively_refcounted : //...
> void listenToAsyncSubsystem()
> // signals will come from another thread
>r, this).track(???)); // can't use here shared_ptr/weak_ptr for tracking }
> I could store a connection object, so that it would be
> destroyed/disconnected in ~intrusively_refcounted(), but I guess it's
> not thread-safe, just like the approach with "trackable".
> So what would be the correct approach?
Could you implement intrusively_refcounted with a pimpl owned by a shared_ptr?
So a group of equivalent intrusively_refcounted objects might share a single
dynamically allocated shared_ptr which the delete when the refcount hits
zero, and it could also be used to obtain a weak_ptr for tracking.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
-----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