-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 6/03/2014 20:09, ttaw wrote: > From: Ulrich Hertlein <u.hertl...@sandbox.de <mailto:u.hertl...@sandbox.de>> > try > m_resource.release().
Thanks, whoever you are. But that moves the ownership from the class to the caller and is not what I'm after. Plus it doesn't solve the potential problem of thread-safety. Cheers, /ulrich > Hi guys, > > during a recent discussion at the office the question was raised whether or > not > there's anything architectural that's stopping the owner of a ref-counted > resource to > return it via a raw pointer and dereference (and hence delete it) before it's > assigned to a receiving ref_ptr. > > Along these lines: caller: Resource* r = foo(); owner: return > m_resource.get() > (separate thread does m_resource.reset() or similar) caller: ref_ptr p(r); > > ref_ptr is assigned return value of 'foo()' which is now a dangling pointer. > (Yes, > you would usually do 'ref_ptr p(foo())' but that's not fundamentally > different from > the above sequence.) > > To the best of my knowledge there's nothing in the design of ref_ptr that > stops > this, but then again I don't believe it's an issue because otherwise we'd > surely have > heard. > > Can anyone think of something (in the ABI, or elsewhere) that would prevent > this? > > Cheers, /ulrich - -- Fingerprint 0227 8EE1 2C64 8EF4 DA11 9864 FF16 0114 B9DA 3318 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBCAAGBQJTGiHVAAoJEP8WARS52jMYpzAH/0GSSjBnQzV1+rQc2Y7/GXtU 5jLJxSurSdezv1bMJ8WylB4L8td2LD2vGEd5nKFNVF7hZHaNIGkXDzA5qEb1MfaW OXwxFu+yVzScxolJx+PT/stZRxsBXocr7X2lJJ1zYdFsWV+QCzN8r+301vcqYqih dToKEA2p4c+a0D3lPla4XvTHkmm1ZK1XQF3iIwxfQucA9UQpKxBC3AVdyxSuwDPG Klqfa0lFXo8OmRrtPHXL3ExPEwwFHAcZQHugwxvxWqI+rICZGQoffpDfs8Nf58JK WNcBIdw4qg2Y9Cc9X4kfimsY7eYyaQ3ihWHLHpYAMUT2+igg92WaZHJ5rpw3L0o= =VwT/ -----END PGP SIGNATURE----- _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org