Changeset 20670

Show
Ignore:
Timestamp:
08/09/07 17:44:52 (1 year ago)
Author:
patrick
Message:

MFT r20666: Tell osg::Referenced when the use of thread-safe reference

counting is needed. The way that this is determined is a hack,
but it's a relatively small one.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OSG/OsgApp.h

    r20669 r20670  
    3030#include <vrj/vrjConfig.h> 
    3131 
     32#include <set> 
     33 
    3234#include <vpr/Sync/Mutex.h> 
    3335#include <vpr/Sync/Guard.h> 
     36#include <vpr/Thread/Thread.h> 
    3437 
    3538#include <vrj/Draw/OGL/GlApp.h> 
     
    380383   int mFrameNumber; 
    381384   vpr::Mutex mSceneViewLock; 
     385   std::set<vpr::Int32> mThreadIDs; 
    382386}; 
    383387 
    384388inline void OsgApp::contextInit() 
    385389{ 
    386    unsigned int unique_context_id = GlDrawManager::instance()->getCurrentContext(); 
     390   // Tell osg::Referenced to use thread-safe reference counting if we detect 
     391   // that there is more than one rendering thread. The means by which we make 
     392   // this determination is less than ideal, but the dynamic configuration 
     393   // aspect of VR Juggler makes this one of the safer options that we have. 
     394   // Nevertheless, this is still a hack, and it should not be mimicked. You 
     395   // have been warned! 
     396   mThreadIDs.insert(vpr::Thread::self()->getTID()); 
     397   osg::Referenced::setThreadSafeReferenceCounting(mThreadIDs.size() > 1); 
     398 
     399   const unsigned int unique_context_id = 
     400      GlDrawManager::instance()->getCurrentContext(); 
    387401 
    388402   // --- Create new context specific scene viewer -- //