Better macro support for switching on/off use of mutex
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
// define used to include in API which is being fazed out
|
||||
// if you can compile your apps with this turned off you are
|
||||
// well placed for compatablity with future versions.
|
||||
#define USE_DEPRECATED_API
|
||||
// #define USE_DEPRECATED_API
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4244 )
|
||||
|
||||
@@ -14,12 +14,15 @@
|
||||
#ifndef OSG_REFERENCED
|
||||
#define OSG_REFERENCED 1
|
||||
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Mutex>
|
||||
|
||||
#include <osg/Export>
|
||||
|
||||
// #define USE_REF_MUTEX 1
|
||||
// #define THREAD_SAFE_REF_UNREF 1
|
||||
|
||||
#ifdef THREAD_SAFE_REF_UNREF
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Mutex>
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
@@ -58,7 +61,7 @@ class SG_EXPORT Referenced
|
||||
this object has another pointer which is referencing it.*/
|
||||
inline void ref() const
|
||||
{
|
||||
#ifdef USE_REF_MUTEX
|
||||
#ifdef THREAD_SAFE_REF_UNREF
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_refMutex);
|
||||
#endif
|
||||
++_refCount;
|
||||
@@ -85,7 +88,7 @@ class SG_EXPORT Referenced
|
||||
protected:
|
||||
virtual ~Referenced();
|
||||
|
||||
#ifdef USE_REF_MUTEX
|
||||
#ifdef THREAD_SAFE_REF_UNREF
|
||||
mutable OpenThreads::Mutex _refMutex;
|
||||
#endif
|
||||
mutable int _refCount;
|
||||
@@ -122,7 +125,7 @@ inline void Referenced::unref() const
|
||||
{
|
||||
bool needDelete = false;
|
||||
{
|
||||
#ifdef USE_REF_MUTEX
|
||||
#ifdef THREAD_SAFE_REF_UNREF
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_refMutex);
|
||||
#endif
|
||||
--_refCount;
|
||||
|
||||
@@ -20,8 +20,11 @@
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
// #define THREAD_SAFE_GLOBJECT_DELETE_LISTS 1
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
||||
// forward declare State & StateSet
|
||||
class State;
|
||||
class StateSet;
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Mutex>
|
||||
#endif
|
||||
|
||||
// if not defined by gl.h use the definition found in:
|
||||
// http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_filter_anisotropic.txt
|
||||
#ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
|
||||
@@ -661,9 +666,10 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
||||
|
||||
TextureObjectListMap _textureObjectListMap;
|
||||
|
||||
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
|
||||
// mutex to keep access serialized.
|
||||
OpenThreads::Mutex _mutex;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
|
||||
return advanceToNextChild(*_composite,_index);
|
||||
}
|
||||
|
||||
inline bool isActive(const CompositeSource& composite,int index)
|
||||
inline bool isActive(const CompositeSource& /*composite*/,int /*index*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user