Hi Richard,
On Tue, Oct 7, 2008 at 3:04 PM, Schmidt, Richard
<[EMAIL PROTECTED]> wrote:
> The DatabaseRequests store observer_ptrs to those nodes where they want
> to insert the node they just loaded.
>
> In the database pager code one will find it in
> void DatabasePager::addLoadedDataToSceneGraph(double timeStamp):
>
> osg::ref_ptr<osg::Group> group =
> databaseRequest->_groupForAddingLoadedSubgraph.get();
>
> In this case it seem to be valid, because addLoadedDataToSceneGraph is
> called by the main thread?!.
osg::observer_ptr<> is used in this case as the
_groupForAddingLoadedSubgraph node has a ref_ptr<> to the
DatabaseRequest, and if it had a ref_ptr<> it'd create a circular
dependency and prevent the node and DatabaseRequest from ever being
deleted.
Whether this particular line is safe is something we'll need to review
carefully. I wrote with the assumption that it would be safe, but
threading is rather wistful beast so I might have missed possible
failure cases.
For there to a be possible failure in this case we'd require
1) ref_ptr<> = observer_ptr<> to not be thread safe
2) for another thread or threads to be able to delete the
_groupForAddingLoadedSubgraph at the same time
as addLoadedDataToSceneGraph is running (or possible even just
the same time as this assignment.)
> However my question is: Is there a thread safe way going from
> observer_ptr to ref_ptr?
Asking the question other way around would be a bit more informative,
what threading combination would lead to a problem with ref_ptr<> to
observer_ptr<> and if there is a problem, what can we do about it.
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org