Hi Robert,

On Mon, 27 Aug 2012 17:58:58 +0200, Robert Osfield <[email protected]> wrote:

Hi Ola,

On 27 August 2012 16:31, Ola Nilsson <[email protected]> wrote:
Yes, the ref count is zero but the destructor chain has not yet completed, by induction it hasn't passed ~TerrainTile. (If it had unregisterTile would
have been called and completed.) Right?

Thinking about your explanation, I think you are correct,the
Terrain::unregisterTile won't be allowed to complete because the
Terrain::traverse() will be holding the Terrain::_mutex so the
destructor won't be able to finish and have the memory fully deleted
and be able to be recycled.

In this situation memory is not yet recycled and the object's parents data
(Referenced) should be safe to access and even manipulate. Right?

Safe... possible, it still doesn't feel robust though.


Agree. If someone registered a tile that wasn't ref counted it wouldn't work. There are some assumptions on usage, but I think most of them apply with the current code.

Please advise if you have any specific scenarios that should be respected.

Btw. the new code passes my modified osgterrain test, which of course
doesn't prove anything...

It's an encouraging start though.  I do wonder if in your changes
there is a need to take a ref_ptr<> and then check for a
referenceCount() of 1, as if the ref count is zero to start with then
just checking against 0 without the ref_ptr<> should be sufficient a
test to see if the object has been deleted.

That was also my initial version. But thinking about worst case I realized that there is a possibility that between a call to getReferenceCount() and the call to ref() or ref_ptr<> constructor another thread might drop the reference count and trigger destruction. Unlikely, but I think possible. By using the ref_ptr the operations should be atomic and safe.

Cheers,

Ola


Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


--
Using Opera's revolutionary email client: http://www.opera.com/mail/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to