Hi Mike, I'm open to seeing use of an atomic count variable in osg::Referenced. The implementation will have to be clean with no extra external dependencies beyond the existing OpenThreads.
W.r.t OSG usage, when the OSG's run multi-threaded the scene graph is ref counted, but the internal parts of the cull and draw traversal are not ref counted - this are all kept in separate structures - one per thread effectively so there is no need to the ref counts, and avoid ref counts here makes a huge difference to performance. I made this change last year as I was seeing near to a double in cull traversal time due to ref counting. The objects in questions all specifically turn off thread safe ref counting, so this would need to be honoured. On the C# side you shouldn't need to worry about internals of the cull and draw side though so you should be able to leave them well alone. A could of things to be aware of w.r.t thread safe ref counting - the default value is set/get by the static member function: /** Set whether reference counting should be use a mutex to create thread reference counting.*/ static void setThreadSafeReferenceCounting(bool enableThreadSafeReferenceCounting); /** Get whether reference counting is active.*/ static bool getThreadSafeReferenceCounting(); Call this before anything else in your app and all objects, except those that explictly don't have thread safe ref counting, will construct with a mutex for the ref count. And for each Referenced object here are methods to set their thread safety: /** Set whether to use a mutex to ensure ref() and unref() are thread safe.*/ virtual void setThreadSafeRefUnref(bool threadSafe); /** Get whether a mutex is used to ensure ref() and unref() are thread safe.*/ bool getThreadSafeRefUnref() const { return _refMutex!=0; } Now a little twist is that in CVS setThreadsafreRefUnref is now a virtual, and is override by classes like Node, Group, Geode, Drawable, StateSet etc so that all the objects below the object that have the ref counting changed for also automatically have the ref counting changed too. This change is implemented to help osgViewer handle new graphics contexts and threading even after the scene graph has been constructed. Robert. _______________________________________________ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/