hi Robert,

just for the sake of clarification .... I dont have circular scenegraph. But
what I do have, I put in userdata nodes from the scene graph. In
Node::setThreadSaferefUnref() you are setting that for the userdata as well.
And from here I get into circle, because the user data contains nodes, that
further in the scene can point to the node that is setting the
ThreadSafeRefUnref (complex scene, mirrors etc, so istenad of creating
custom nodes I use UserData).

Nick

http://www.linkedin.com/in/tnick


On Thu, Feb 4, 2010 at 5:51 PM, Robert Osfield <[email protected]>wrote:

> Hi Nick,
>
> Thread safe ref/unref makes no differences to circular references that
> you create in your application/scene graph.  It's simply not safe to
> create circular references, you have to break them to be able to avoid
> memory leaks and the best way to do this is to use an osg::Observer,
> observer_ptr<> or a straight C pointer.  The later you have to be
> careful about dangling pointers though.
>
> Robert.
>
> On Thu, Feb 4, 2010 at 3:27 PM, Trajce Nikolov <[email protected]>
> wrote:
> > the thing that causes me troubles is the user data. I ran into a case of
> > making the scene graph cyclic. I store in user data some nodes, so it
> ended
> > up into infinite loop when adding a new view (startThreading sets this to
> a
> > value). So my point is to have something like
> > "if (node->getThreadSafeUnref() != newVal)
> > node->setThreadSafeUnref(newVal))"
> > I know I can override this in my own class and implement it. Since this
> is
> > called once in a while, I dont think it will be big overhead.
> > Nick
> >
> > http://www.linkedin.com/in/tnick
> >
> >
> > On Thu, Feb 4, 2010 at 5:22 PM, Robert Osfield <[email protected]
> >
> > wrote:
> >>
> >> Hi Nick,
> >>
> >> On Thu, Feb 4, 2010 at 1:53 PM, Trajce Nikolov <
> [email protected]>
> >> wrote:
> >> > can we make this call to change the settings only if it different from
> >> > the
> >> > current one?
> >>
> >> It only has an effect when you don't have atomic reference counting
> >> built-in, in which case it toggles whether it'll use a mutex to make
> >> sure ref/unref and thread safe.  If you have atomic ref counting built
> >> in then then you can't change it, it's always thread safe as the cost
> >> of adding an if statement would be more expensive than just doing the
> >> atmoic increment/decrement.
> >>
> >> Robert.
> >> _______________________________________________
> >> osg-users mailing list
> >> [email protected]
> >>
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> >
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> >
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to