Hi Allen,

Allen Bierbaum wrote:
> I propose that we use boost::shared_ptrs and OSG::RefPtr's to make the 
> user-level API's of OpenSG 2.0 safer to use.  More specifically I 
> suggest that we:
>
> - Make create for non-fc types return boost::shared_ptr<>'s and that we 
> traffic in these ptrs in the user API.
> - Merge the capabilities of RefPtr into whatever FCPtr class becomes the 
> final standard
> - All user-level APIs would return and take smart pointer style 
> arguments that would automatically handle memory management
>
> This change would be extensive, but once it is done I think the system 
> would be much better off for it.
>   
That was the basic idea I've been expecting to do anyway, once we have 
decided whether to get rid of the FCptr hierarchy or not.
> So, let's talk about reasons that it can't or shouldn't be done and how 
> we can work around them.
>
> - Performance:  We don't want to give up performance.  During traversals 
> and other highly recursive calls, fcptr's will be passed as arguments 
> many times.  We don't want each of these times to require a add/sub ref 
> because those calls are expensive. 
>
> A solution to this problem would be to allow the internal APIs to pass 
> around cptr's to maintain high-performance.  I haven't looked at the 
> code yet so can someone else tell me if this would work?
>   
I'm all for it.
> - Cycles: There may be places in the code where we need back references. 
>
> Boost solves this by using a weak_ptr.  Weak_ptrs are factory objects 
> that can create shared_ptr's but will return a Null ptr if the object it 
> points to has been destroyed (no shared_ptrs still holding it).  We 
> could probably create a similar ptr type WeakRefPtr to work for the 
> RefPtr types.  We could base the implementation off of the 
> implementation that boost uses for shared_ptr and weak_ptr.
>
> Comments, concerns, flames?  :)
>   
Where would we encounter those. The obvious one I can think of are 
parent pointers. I think using weak_ptr for the parent pointers should 
work. This would horribly break existing applications that use cptrs, 
but they would have to change anyway. I can't think of any other cases 
that have cycles in them right now. Am I missing something?

    Dirk


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-core

Reply via email to