Changeset 3222

Show
Ignore:
Timestamp:
08/03/04 13:01:39 (10 years ago)
Author:
robert
Message:

Better macro support for switching on/off use of mutex

Location:
OpenSceneGraph/trunk
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osg/Export

    r1927 r3222  
    1818// if you can compile your apps with this turned off you are 
    1919// well placed for compatablity with future versions. 
    20 #define USE_DEPRECATED_API 
     20// #define USE_DEPRECATED_API 
    2121 
    2222#if defined(_MSC_VER) 
  • OpenSceneGraph/trunk/include/osg/Referenced

    r3190 r3222  
    1515#define OSG_REFERENCED 1 
    1616 
    17 #include <OpenThreads/ScopedLock> 
    18 #include <OpenThreads/Mutex> 
    1917 
    2018#include <osg/Export> 
    2119 
    22 // #define USE_REF_MUTEX 1 
     20// #define THREAD_SAFE_REF_UNREF 1 
     21 
     22#ifdef THREAD_SAFE_REF_UNREF 
     23    #include <OpenThreads/ScopedLock> 
     24    #include <OpenThreads/Mutex> 
     25#endif 
    2326 
    2427namespace osg { 
     
    5962        inline void ref() const 
    6063        {  
    61 #ifdef USE_REF_MUTEX 
     64#ifdef THREAD_SAFE_REF_UNREF 
    6265            OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_refMutex);  
    6366#endif 
     
    8689        virtual ~Referenced(); 
    8790         
    88 #ifdef USE_REF_MUTEX 
     91#ifdef THREAD_SAFE_REF_UNREF 
    8992        mutable OpenThreads::Mutex  _refMutex; 
    9093#endif 
     
    123126    bool needDelete = false; 
    124127    { 
    125 #ifdef USE_REF_MUTEX 
     128#ifdef THREAD_SAFE_REF_UNREF 
    126129        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_refMutex);  
    127130#endif 
  • OpenSceneGraph/trunk/include/osg/StateAttribute

    r3159 r3222  
    2121#include <typeinfo> 
    2222 
     23// #define THREAD_SAFE_GLOBJECT_DELETE_LISTS 1 
     24 
    2325namespace osg { 
     26 
    2427 
    2528// forward declare State & StateSet 
  • OpenSceneGraph/trunk/include/osg/Texture

    r3190 r3222  
    2424#include <list> 
    2525#include <map> 
     26 
     27#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
     28    #include <OpenThreads/ScopedLock> 
     29    #include <OpenThreads/Mutex> 
     30#endif 
    2631 
    2732// if not defined by gl.h use the definition found in: 
     
    662667            TextureObjectListMap    _textureObjectListMap; 
    663668             
     669#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    664670            // mutex to keep access serialized. 
    665671            OpenThreads::Mutex      _mutex; 
    666              
     672#endif             
    667673        }; 
    668674         
  • OpenSceneGraph/trunk/include/osgTerrain/DataSet

    r3151 r3222  
    478478                    } 
    479479 
    480                     inline bool isActive(const CompositeSource& composite,int index) 
     480                    inline bool isActive(const CompositeSource& /*composite*/,int /*index*/) 
    481481                    { 
    482482                        return true; 
  • OpenSceneGraph/trunk/src/osg/Drawable.cpp

    r3171 r3222  
    2727#include <list> 
    2828 
     29#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
     30    #include <OpenThreads/ScopedLock> 
     31    #include <OpenThreads/Mutex> 
     32#endif 
     33 
    2934using namespace osg; 
    3035 
     
    3540typedef std::map<GLuint,DisplayListList> DeletedDisplayListCache; 
    3641 
    37 static OpenThreads::Mutex s_mutex_deletedDisplayListCache; 
     42#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
     43   static OpenThreads::Mutex s_mutex_deletedDisplayListCache; 
     44#endif 
     45 
    3846static DeletedDisplayListCache s_deletedDisplayListCache; 
    3947 
     
    4250    if (globj!=0) 
    4351    { 
    44 #ifdef THREAD_SAFE_DELETE_LISTS 
     52#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    4553        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedDisplayListCache); 
    4654#endif 
     
    6472 
    6573    { 
    66 #ifdef THREAD_SAFE_DELETE_LISTS 
     74#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    6775        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedDisplayListCache); 
    6876#endif 
     
    9199 
    92100 
    93 static OpenThreads::Mutex s_mutex_deletedVertexBufferObjectCache; 
     101#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
     102    static OpenThreads::Mutex s_mutex_deletedVertexBufferObjectCache; 
     103#endif 
    94104static DeletedDisplayListCache s_deletedVertexBufferObjectCache; 
    95105 
     
    98108    if (globj!=0) 
    99109    { 
    100 #ifdef THREAD_SAFE_DELETE_LISTS 
     110#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    101111        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexBufferObjectCache); 
    102112#endif 
     
    120130 
    121131    { 
    122 #ifdef THREAD_SAFE_DELETE_LISTS 
     132#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    123133        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexBufferObjectCache); 
    124134#endif 
  • OpenSceneGraph/trunk/src/osg/FragmentProgram.cpp

    r3215 r3222  
    1919#include <list> 
    2020 
     21#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
     22    #include <OpenThreads/ScopedLock> 
     23    #include <OpenThreads/Mutex> 
     24#endif 
     25 
    2126using namespace osg; 
    2227 
     
    2732typedef std::map<unsigned int,FragmentProgramObjectList> DeletedFragmentProgramObjectCache; 
    2833 
    29 static OpenThreads::Mutex                s_mutex_deletedFragmentProgramObjectCache; 
     34#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
     35    static OpenThreads::Mutex                s_mutex_deletedFragmentProgramObjectCache; 
     36#endif 
    3037static DeletedFragmentProgramObjectCache s_deletedFragmentProgramObjectCache; 
    3138 
     
    3441    if (handle!=0) 
    3542    { 
    36 #ifdef THREAD_SAFE_DELETE_LISTS 
     43#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    3744        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedFragmentProgramObjectCache); 
    3845#endif 
     
    5461 
    5562    { 
    56 #ifdef THREAD_SAFE_DELETE_LISTS 
     63#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    5764        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedFragmentProgramObjectCache); 
    5865#endif 
  • OpenSceneGraph/trunk/src/osg/Texture.cpp

    r3215 r3222  
    7171                                                                             GLint     border) 
    7272{ 
    73 #ifdef THREAD_SAFE_DELETE_LISTS 
     73#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    7474    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); 
    7575#endif 
     
    9999void Texture::TextureObjectManager::addTextureObjects(Texture::TextureObjectListMap& toblm) 
    100100{ 
    101 #ifdef THREAD_SAFE_DELETE_LISTS 
     101#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    102102    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); 
    103103#endif 
     
    114114void Texture::TextureObjectManager::addTextureObjectsFrom(Texture& texture) 
    115115{ 
     116#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    116117    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); 
     118#endif 
    117119 
    118120    texture.takeTextureObjects(_textureObjectListMap); 
     
    130132 
    131133    {     
    132 #ifdef THREAD_SAFE_DELETE_LISTS 
     134#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    133135        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); 
    134136#endif 
     
    10771079        if (_textureObjectBuffer[contextID].valid())  
    10781080        { 
     1081#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    10791082            OpenThreads::ScopedLock<OpenThreads::Mutex> lock(getTextureObjectManager()->_mutex); 
     1083#endif 
    10801084             
    10811085            getTextureObjectManager()->_textureObjectListMap[contextID].push_back(_textureObjectBuffer[contextID]); 
  • OpenSceneGraph/trunk/src/osg/VertexProgram.cpp

    r3215 r3222  
    1919#include <list> 
    2020 
     21#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
     22    #include <OpenThreads/ScopedLock> 
     23    #include <OpenThreads/Mutex> 
     24#endif 
     25 
    2126using namespace osg; 
    2227 
     
    2732typedef std::map<unsigned int,VertexProgramObjectList> DeletedVertexProgramObjectCache; 
    2833 
    29 static OpenThreads::Mutex              s_mutex_deletedVertexProgramObjectCache; 
     34#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
     35    static OpenThreads::Mutex              s_mutex_deletedVertexProgramObjectCache; 
     36#endif 
    3037static DeletedVertexProgramObjectCache s_deletedVertexProgramObjectCache; 
    3138 
     
    3441    if (handle!=0) 
    3542    { 
    36 #ifdef THREAD_SAFE_DELETE_LISTS 
     43#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    3744        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexProgramObjectCache); 
    3845#endif 
     
    5461 
    5562    { 
    56 #ifdef THREAD_SAFE_DELETE_LISTS 
     63#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    5764        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexProgramObjectCache); 
    5865#endif 
  • OpenSceneGraph/trunk/src/osgGL2/ProgramObject.cpp

    r3217 r3222  
    3232#include <list> 
    3333 
     34#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
     35    #include <OpenThreads/ScopedLock> 
     36    #include <OpenThreads/Mutex> 
     37#endif 
     38 
    3439using namespace osgGL2; 
    3540 
     
    7782typedef std::map<unsigned int, GL2ObjectList> DeletedGL2ObjectCache; 
    7883 
    79 static OpenThreads::Mutex    s_mutex_deletedGL2ObjectCache; 
     84#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
     85    static OpenThreads::Mutex    s_mutex_deletedGL2ObjectCache; 
     86#endif 
    8087static DeletedGL2ObjectCache s_deletedGL2ObjectCache; 
    8188 
     
    8491    if (handle!=0) 
    8592    { 
    86 #ifdef THREAD_SAFE_DELETE_LISTS 
     93#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    8794        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedGL2ObjectCache); 
    8895#endif 
     
    102109 
    103110    { 
    104 #ifdef THREAD_SAFE_DELETE_LISTS 
     111#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS 
    105112        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedGL2ObjectCache); 
    106113#endif