On 1 August 2013 15:09, Paul Martz <[email protected]> wrote:
> You can pass references to shared_ptr objects. You only need to copy them
> for long-term storage, which is typically not a performance critical
> operation in a scene graph.

It occurred to me that a reference to a shared_ptr<> is actually a
pointer to a pointer, and depending upon the implementation details of
shared_ptr<> it could well be a pointer to pointer to pointer just to
get access to the object and it's methods.

So efficiency wise I don't think a returning a shared_ptr<>& is going
to be as efficient as just passing back a C* like the OSG does at
present, if fact I think there is probably quite a big difference in
performance.  And as Mathias mentions that's without considering the
extra memory allocations that associated with shared_ptr<> over a
intrusive ref_ptr<> design.

My conclusion would be the shared_ptr<> is clever, but it's ability to
be a general purpose smart pointer impacts the performance of it usage
over intrusive ref_ptr<>. For a scene graphs with a consistent class
hierachy and with this ability to provide intrusive ref/unref() makes
intrusive smart pointers a better performing and lighter weight
solution.  Like Mathias also suggested, using of std::atomic looks to
be very useful and will simplify codes.  Same applies to other
std::thread related functionality.

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

Reply via email to