Better macro support for switching on/off use of mutex
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user