Hello all:

I am just starting to play with the new WeakPtr types in OpenSG.  Very nice.

I have one suggestion for the documentation.  I think we should
recommend a usage idiom for people to only use WeakPtr's if they have
first been converted to Rec/Ref Ptrs.  This would be similar to the
recommended usage of boost weak pointers.
(http://www.boost.org/doc/libs/1_38_0/libs/smart_ptr/weak_ptr.htm)

The reasoning is that there is no general way to guarantee that the
following code will work:

NodeWeakPtr n = someOtherRef;

[do something]

if(n != NULL)
{
    std::cout << "n points to a live Node" << std::endl;
}

If instead it was like this:

NodeWeakPtr n = someOtherRef;

NodeRefPtr temp_ref(n);

if(temp_ref != NULL)
{
    std::cout << "temp_ref points to a live Node" << std::endl;
}

then the reference counting mechanisms will ensure that everything
works ok.  I know that this also relates to using multiple threads,
but it just seems safer to me to recommend that people use a safer
idiom like this.

Anyway, that is my 2 cents.

-Allen

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Opensg-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-core

Reply via email to