Hi,

On Thursday 02 October 2008 09:08, Ulrich Hertlein wrote:
> Yes, but this is a usage error w.r.t. shared_ptr<>.
> You always need to pass the shared_ptr<> but that works just as well.
Sure, but osg does not and this even makes sense ...

> > Note that this kind of usage pattern happens quiet often in osg ...
> > ... think of adding nodes to a group and adding the same node to an other
> > group and many more.
>
> The OSG API would have to be adapted of course so that the raw pointers are
> never passed back but only references (or copies) of the internal
> shared_ptr<>.
Sure, but IMO the current usage pattern makes sense.
When you only pass shared_ptr's then the reference count is expected to change 
much more often than it happens now. And even in the presence of that atomic 
stuff, this is relatively expensive since such an atomic operation needs to 
inform the other cpu's that there has something happened. You can measure 
this. Also keep in mind, that the atomic counts do not work everywhere ...
Osg has some places in the cull stage for example, where the rendering backend 
has just plain pointers to Referenced derived classes for performance 
reasons. I have done performance measurements with ref_ptr's in these places, 
but counting even with the atomic stuff really hurts performance. So using 
shared_ptr's in *really* *any* place is not an option IMO.
I do not know if these raw pointes are somewhere again used to initialize 
ref_ptr's for some special cases.
So, this usage pattern happens, and it even sometimes happens in very subtile 
ways.
The current implementation works well with a usage pattern that really makes 
sense here ...

> I'm not trying to advocate usage of shared_ptr<> in OSG, I'm just saying it
> could be done - but it would also break a lot of code.
Sure ...

Greetings

Mathias

-- 
Dr. Mathias Fröhlich, science + computing ag, Software Solutions
Hagellocher Weg 71-75, D-72070 Tuebingen, Germany
Phone: +49 7071 9457-268, Fax: +49 7071 9457-511
-- 
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Florian Geyer,
Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Prof. Dr. Hanns Ruder
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 

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

Reply via email to