Moved Block, ReentrantMutex and ReadWriteMutex into OpenThreads.

This commit is contained in:
Robert Osfield 2007-02-23 16:31:34 +00:00
parent 968a8d1118
commit ad3cac84e9
30 changed files with 67 additions and 343 deletions

View File

@ -215,10 +215,6 @@ SOURCE=..\..\Src\osgDB\Registry.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\Src\osgDB\ReentrantMutex.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\osgDB\SharedStateManager.cpp SOURCE=..\..\src\osgDB\SharedStateManager.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -303,10 +299,6 @@ SOURCE=..\..\Include\osgDB\Registry
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\Include\osgDB\ReentrantMutex
# End Source File
# Begin Source File
SOURCE=..\..\Include\osgDB\SharedStateManager SOURCE=..\..\Include\osgDB\SharedStateManager
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -147,10 +147,6 @@ SOURCE=..\..\..\src\osgWrappers\osgDB\ParameterOutput.cpp
SOURCE=..\..\..\src\osgWrappers\osgDB\ReaderWriter.cpp SOURCE=..\..\..\src\osgWrappers\osgDB\ReaderWriter.cpp
# End Source File # End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgDB\ReentrantMutex.cpp
# End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgDB\Registry.cpp SOURCE=..\..\..\src\osgWrappers\osgDB\Registry.cpp
# End Source File # End Source File

View File

@ -1910,9 +1910,7 @@
00E2813D07676504005AEE61 /* dxtctool.h in Headers */ = {isa = PBXBuildFile; fileRef = 00E2813A07676502005AEE61 /* dxtctool.h */; }; 00E2813D07676504005AEE61 /* dxtctool.h in Headers */ = {isa = PBXBuildFile; fileRef = 00E2813A07676502005AEE61 /* dxtctool.h */; };
00E2813E07676504005AEE61 /* TexEnvFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00E2813B07676503005AEE61 /* TexEnvFilter.cpp */; }; 00E2813E07676504005AEE61 /* TexEnvFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00E2813B07676503005AEE61 /* TexEnvFilter.cpp */; };
00E2814107676629005AEE61 /* Archive in Headers */ = {isa = PBXBuildFile; fileRef = 00E2813F07676626005AEE61 /* Archive */; settings = {ATTRIBUTES = (Public, ); }; }; 00E2814107676629005AEE61 /* Archive in Headers */ = {isa = PBXBuildFile; fileRef = 00E2813F07676626005AEE61 /* Archive */; settings = {ATTRIBUTES = (Public, ); }; };
00E2814207676629005AEE61 /* ReentrantMutex in Headers */ = {isa = PBXBuildFile; fileRef = 00E2814007676628005AEE61 /* ReentrantMutex */; settings = {ATTRIBUTES = (Public, ); }; };
00E28145076766DA005AEE61 /* Archive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00E28143076766D7005AEE61 /* Archive.cpp */; }; 00E28145076766DA005AEE61 /* Archive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00E28143076766D7005AEE61 /* Archive.cpp */; };
00E28146076766DA005AEE61 /* ReentrantMutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00E28144076766D9005AEE61 /* ReentrantMutex.cpp */; };
00E28148076767D2005AEE61 /* NodeTrackerManipulator in Headers */ = {isa = PBXBuildFile; fileRef = 00E28147076767D1005AEE61 /* NodeTrackerManipulator */; settings = {ATTRIBUTES = (Public, ); }; }; 00E28148076767D2005AEE61 /* NodeTrackerManipulator in Headers */ = {isa = PBXBuildFile; fileRef = 00E28147076767D1005AEE61 /* NodeTrackerManipulator */; settings = {ATTRIBUTES = (Public, ); }; };
00E2814A07676854005AEE61 /* NodeTrackerManipulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00E2814907676852005AEE61 /* NodeTrackerManipulator.cpp */; }; 00E2814A07676854005AEE61 /* NodeTrackerManipulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00E2814907676852005AEE61 /* NodeTrackerManipulator.cpp */; };
00E281A607676B93005AEE61 /* FindExternalModelVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00E281A407676B91005AEE61 /* FindExternalModelVisitor.cpp */; }; 00E281A607676B93005AEE61 /* FindExternalModelVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00E281A407676B91005AEE61 /* FindExternalModelVisitor.cpp */; };
@ -6053,9 +6051,7 @@
00E2813A07676502005AEE61 /* dxtctool.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = dxtctool.h; path = ../../src/osg/dxtctool.h; sourceTree = SOURCE_ROOT; }; 00E2813A07676502005AEE61 /* dxtctool.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = dxtctool.h; path = ../../src/osg/dxtctool.h; sourceTree = SOURCE_ROOT; };
00E2813B07676503005AEE61 /* TexEnvFilter.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = TexEnvFilter.cpp; path = ../../src/osg/TexEnvFilter.cpp; sourceTree = SOURCE_ROOT; }; 00E2813B07676503005AEE61 /* TexEnvFilter.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = TexEnvFilter.cpp; path = ../../src/osg/TexEnvFilter.cpp; sourceTree = SOURCE_ROOT; };
00E2813F07676626005AEE61 /* Archive */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; name = Archive; path = ../../include/osgDB/Archive; sourceTree = SOURCE_ROOT; }; 00E2813F07676626005AEE61 /* Archive */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; name = Archive; path = ../../include/osgDB/Archive; sourceTree = SOURCE_ROOT; };
00E2814007676628005AEE61 /* ReentrantMutex */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; name = ReentrantMutex; path = ../../include/osgDB/ReentrantMutex; sourceTree = SOURCE_ROOT; };
00E28143076766D7005AEE61 /* Archive.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Archive.cpp; path = ../../src/osgDB/Archive.cpp; sourceTree = SOURCE_ROOT; }; 00E28143076766D7005AEE61 /* Archive.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Archive.cpp; path = ../../src/osgDB/Archive.cpp; sourceTree = SOURCE_ROOT; };
00E28144076766D9005AEE61 /* ReentrantMutex.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ReentrantMutex.cpp; path = ../../src/osgDB/ReentrantMutex.cpp; sourceTree = SOURCE_ROOT; };
00E28147076767D1005AEE61 /* NodeTrackerManipulator */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; path = NodeTrackerManipulator; sourceTree = "<group>"; }; 00E28147076767D1005AEE61 /* NodeTrackerManipulator */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; path = NodeTrackerManipulator; sourceTree = "<group>"; };
00E2814907676852005AEE61 /* NodeTrackerManipulator.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = NodeTrackerManipulator.cpp; path = ../../src/osgGA/NodeTrackerManipulator.cpp; sourceTree = SOURCE_ROOT; }; 00E2814907676852005AEE61 /* NodeTrackerManipulator.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = NodeTrackerManipulator.cpp; path = ../../src/osgGA/NodeTrackerManipulator.cpp; sourceTree = SOURCE_ROOT; };
00E281A407676B91005AEE61 /* FindExternalModelVisitor.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = FindExternalModelVisitor.cpp; path = ../../src/osgPlugins/flt/FindExternalModelVisitor.cpp; sourceTree = SOURCE_ROOT; }; 00E281A407676B91005AEE61 /* FindExternalModelVisitor.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = FindExternalModelVisitor.cpp; path = ../../src/osgPlugins/flt/FindExternalModelVisitor.cpp; sourceTree = SOURCE_ROOT; };
@ -11506,7 +11502,6 @@
BE1188F405D765CD00EB53E5 /* Output.cpp */, BE1188F405D765CD00EB53E5 /* Output.cpp */,
BE1188F505D765CD00EB53E5 /* ReadFile.cpp */, BE1188F505D765CD00EB53E5 /* ReadFile.cpp */,
008F446B06CBF99E00F4220C /* ReaderWriter.cpp */, 008F446B06CBF99E00F4220C /* ReaderWriter.cpp */,
00E28144076766D9005AEE61 /* ReentrantMutex.cpp */,
BE1188F605D765CD00EB53E5 /* Registry.cpp */, BE1188F605D765CD00EB53E5 /* Registry.cpp */,
BE1188F705D765CD00EB53E5 /* SharedStateManager.cpp */, BE1188F705D765CD00EB53E5 /* SharedStateManager.cpp */,
BE1188F805D765CD00EB53E5 /* Version.cpp */, BE1188F805D765CD00EB53E5 /* Version.cpp */,
@ -11534,7 +11529,6 @@
BE11891705D7665600EB53E5 /* ParameterOutput */, BE11891705D7665600EB53E5 /* ParameterOutput */,
BE11891805D7665600EB53E5 /* ReaderWriter */, BE11891805D7665600EB53E5 /* ReaderWriter */,
BE11891905D7665600EB53E5 /* ReadFile */, BE11891905D7665600EB53E5 /* ReadFile */,
00E2814007676628005AEE61 /* ReentrantMutex */,
BE11891A05D7665600EB53E5 /* Registry */, BE11891A05D7665600EB53E5 /* Registry */,
BE11891B05D7665600EB53E5 /* SharedStateManager */, BE11891B05D7665600EB53E5 /* SharedStateManager */,
BE11891C05D7665600EB53E5 /* Version */, BE11891C05D7665600EB53E5 /* Version */,
@ -13274,7 +13268,6 @@
BE11892A05D7665600EB53E5 /* ParameterOutput in Headers */, BE11892A05D7665600EB53E5 /* ParameterOutput in Headers */,
BE11892B05D7665600EB53E5 /* ReaderWriter in Headers */, BE11892B05D7665600EB53E5 /* ReaderWriter in Headers */,
BE11892C05D7665600EB53E5 /* ReadFile in Headers */, BE11892C05D7665600EB53E5 /* ReadFile in Headers */,
00E2814207676629005AEE61 /* ReentrantMutex in Headers */,
BE11892D05D7665600EB53E5 /* Registry in Headers */, BE11892D05D7665600EB53E5 /* Registry in Headers */,
BE11892E05D7665600EB53E5 /* SharedStateManager in Headers */, BE11892E05D7665600EB53E5 /* SharedStateManager in Headers */,
BE11892F05D7665600EB53E5 /* Version in Headers */, BE11892F05D7665600EB53E5 /* Version in Headers */,
@ -19037,7 +19030,6 @@
BE11890A05D765CE00EB53E5 /* WriteFile.cpp in Sources */, BE11890A05D765CE00EB53E5 /* WriteFile.cpp in Sources */,
008F446C06CBF99E00F4220C /* ReaderWriter.cpp in Sources */, 008F446C06CBF99E00F4220C /* ReaderWriter.cpp in Sources */,
00E28145076766DA005AEE61 /* Archive.cpp in Sources */, 00E28145076766DA005AEE61 /* Archive.cpp in Sources */,
00E28146076766DA005AEE61 /* ReentrantMutex.cpp in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@ -18,11 +18,11 @@
#include <osgDB/ImageOptions> #include <osgDB/ImageOptions>
#include <OpenThreads/ScopedLock> #include <OpenThreads/ScopedLock>
#include <osgDB/ReentrantMutex> #include <OpenThreads/ReentrantMutex>
#include "PhotoArchive.h" #include "PhotoArchive.h"
#define SERIALIZER() OpenThreads::ScopedLock<osgDB::ReentrantMutex> lock(_serializerMutex) #define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
class ImageReaderWriter : public osgDB::ReaderWriter class ImageReaderWriter : public osgDB::ReaderWriter
{ {
@ -53,7 +53,7 @@ class ImageReaderWriter : public osgDB::ReaderWriter
ReadResult local_readNode(const std::string& fileName, const Options*); ReadResult local_readNode(const std::string& fileName, const Options*);
mutable osgDB::ReentrantMutex _serializerMutex; mutable OpenThreads::ReentrantMutex _serializerMutex;
struct DataReference struct DataReference
{ {

View File

@ -189,7 +189,7 @@ class OSG_EXPORT GraphicsContext : public Object
OpenThreads::Mutex* getOperationsMutex() { return &_operationsMutex; } OpenThreads::Mutex* getOperationsMutex() { return &_operationsMutex; }
/** Get the operations queue block used to mark an empty queue, if you end items into the empty queu you must release this block.*/ /** Get the operations queue block used to mark an empty queue, if you end items into the empty queu you must release this block.*/
osg::Block* getOperationsBlock() { return _operationsBlock.get(); } osg::RefBlock* getOperationsBlock() { return _operationsBlock.get(); }
/** Get the current operations that is being run.*/ /** Get the current operations that is being run.*/
Operation* getCurrentOperation() { return _currentOperation.get(); } Operation* getCurrentOperation() { return _currentOperation.get(); }
@ -381,7 +381,7 @@ class OSG_EXPORT GraphicsContext : public Object
OpenThreads::Thread* _threadOfLastMakeCurrent; OpenThreads::Thread* _threadOfLastMakeCurrent;
OpenThreads::Mutex _operationsMutex; OpenThreads::Mutex _operationsMutex;
osg::ref_ptr<osg::Block> _operationsBlock; osg::ref_ptr<osg::RefBlock> _operationsBlock;
OperationQueue _operations; OperationQueue _operations;
osg::ref_ptr<Operation> _currentOperation; osg::ref_ptr<Operation> _currentOperation;

View File

@ -20,58 +20,18 @@
#include <OpenThreads/Thread> #include <OpenThreads/Thread>
#include <OpenThreads/Barrier> #include <OpenThreads/Barrier>
#include <OpenThreads/Condition> #include <OpenThreads/Condition>
#include <OpenThreads/Block>
#include <list> #include <list>
namespace osg { namespace osg {
class Block: virtual public osg::Referenced { class RefBlock: virtual public osg::Referenced, public OpenThreads::Block
{
public: public:
Block():_released(false) {}
inline void block() RefBlock() {}
{
OpenThreads::ScopedLock<OpenThreads::Mutex> mutlock(_mut);
if( !_released )
_cond.wait(&_mut);
}
inline void release()
{
OpenThreads::ScopedLock<OpenThreads::Mutex> mutlock(_mut);
if (!_released)
{
_released = true;
_cond.broadcast();
}
}
inline void reset()
{
OpenThreads::ScopedLock<OpenThreads::Mutex> mutlock(_mut);
_released = false;
}
inline void set(bool doRelease)
{
if (doRelease!=_released)
{
if (doRelease) release();
else reset();
}
}
protected:
~Block()
{
release();
}
private:
OpenThreads::Mutex _mut;
OpenThreads::Condition _cond;
bool _released;
}; };
/** Base class for implementing graphics operations.*/ /** Base class for implementing graphics operations.*/
@ -155,7 +115,7 @@ class OSG_EXPORT OperationsThread : public Referenced, public OpenThreads::Threa
bool _done; bool _done;
OpenThreads::Mutex _operationsMutex; OpenThreads::Mutex _operationsMutex;
osg::ref_ptr<osg::Block> _operationsBlock; osg::ref_ptr<osg::RefBlock> _operationsBlock;
OperationQueue _operations; OperationQueue _operations;
osg::ref_ptr<Operation> _currentOperation; osg::ref_ptr<Operation> _currentOperation;
@ -195,7 +155,7 @@ struct OSG_EXPORT BarrierOperation : public Operation, public OpenThreads::Barri
/** ReleaseContext_Block_MakeCurrentOperation releases the context for another thread to aquire, /** ReleaseContext_Block_MakeCurrentOperation releases the context for another thread to aquire,
* then blocks waiting for context to be released, once the block is release the context is re-aqquired.*/ * then blocks waiting for context to be released, once the block is release the context is re-aqquired.*/
struct OSG_EXPORT ReleaseContext_Block_MakeCurrentOperation : public Operation, public Block struct OSG_EXPORT ReleaseContext_Block_MakeCurrentOperation : public Operation, public RefBlock
{ {
ReleaseContext_Block_MakeCurrentOperation(): ReleaseContext_Block_MakeCurrentOperation():
Operation("ReleaseContext_Block_MakeCurrent", false) {} Operation("ReleaseContext_Block_MakeCurrent", false) {}

View File

@ -84,7 +84,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
/** Get the whether UseFrameBlock is on or off.*/ /** Get the whether UseFrameBlock is on or off.*/
bool getUseFrameBlock() const { return _useFrameBlock; } bool getUseFrameBlock() const { return _useFrameBlock; }
osg::Block* getFrameBlock() { return _frameBlock.get(); } osg::RefBlock* getFrameBlock() { return _frameBlock.get(); }
/** Set the priority of the database pager thread during the frame (i.e. while cull and draw are running.)*/ /** Set the priority of the database pager thread during the frame (i.e. while cull and draw are running.)*/
void setThreadPriorityDuringFrame(ThreadPriority duringFrame) { _threadPriorityDuringFrame = duringFrame; } void setThreadPriorityDuringFrame(ThreadPriority duringFrame) { _threadPriorityDuringFrame = duringFrame; }
@ -293,7 +293,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
bool _startThreadCalled; bool _startThreadCalled;
osg::ref_ptr<osg::Block> _databasePagerThreadBlock; osg::ref_ptr<osg::RefBlock> _databasePagerThreadBlock;
inline void updateDatabasePagerThreadBlock() inline void updateDatabasePagerThreadBlock()
{ {
@ -325,7 +325,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
bool _useFrameBlock; bool _useFrameBlock;
int _numFramesActive; int _numFramesActive;
mutable OpenThreads::Mutex _numFramesActiveMutex; mutable OpenThreads::Mutex _numFramesActiveMutex;
osg::ref_ptr<osg::Block> _frameBlock; osg::ref_ptr<osg::RefBlock> _frameBlock;
int _frameNumber; int _frameNumber;
ThreadPriority _threadPriorityDuringFrame; ThreadPriority _threadPriorityDuringFrame;

View File

@ -1,108 +0,0 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGDB_REENTRANTMUTEX
#define OSGDB_REENTRANTMUTEX
#include <OpenThreads/Thread>
#include <OpenThreads/Mutex>
#include <osgDB/Export>
namespace osgDB {
class OSGDB_EXPORT ReentrantMutex : public OpenThreads::Mutex
{
public:
ReentrantMutex();
virtual ~ReentrantMutex();
virtual int lock();
virtual int unlock();
virtual int trylock();
private:
ReentrantMutex(const ReentrantMutex&):OpenThreads::Mutex() {}
ReentrantMutex& operator =(const ReentrantMutex&) { return *(this); }
OpenThreads::Thread* _threadHoldingMutex;
OpenThreads::Mutex _lockCountMutex;
unsigned int _lockCount;
};
class OSGDB_EXPORT ReadWriteMutex
{
public:
ReadWriteMutex();
virtual ~ReadWriteMutex();
virtual int readLock();
virtual int readUnlock();
virtual int writeLock();
virtual int writeUnlock();
protected:
ReadWriteMutex(const ReadWriteMutex&) {}
ReadWriteMutex& operator = (const ReadWriteMutex&) { return *(this); }
#if 0
ReentrantMutex _readWriteMutex;
ReentrantMutex _readCountMutex;
#else
OpenThreads::Mutex _readWriteMutex;
OpenThreads::Mutex _readCountMutex;
#endif
unsigned int _readCount;
};
class ScopedReadLock
{
public:
ScopedReadLock(ReadWriteMutex& mutex):_mutex(mutex) { _mutex.readLock(); }
~ScopedReadLock() { _mutex.readUnlock(); }
protected:
ReadWriteMutex& _mutex;
};
class ScopedWriteLock
{
public:
ScopedWriteLock(ReadWriteMutex& mutex):_mutex(mutex) { _mutex.writeLock(); }
~ScopedWriteLock() { _mutex.writeUnlock(); }
protected:
ReadWriteMutex& _mutex;
};
}
#endif

View File

@ -30,7 +30,7 @@
#include <osg/Vec3> #include <osg/Vec3>
#include <osg/BoundingBox> #include <osg/BoundingBox>
#include <osgDB/ReentrantMutex> #include <OpenThreads/ReadWriteMutex>
namespace osgParticle namespace osgParticle
{ {
@ -166,7 +166,7 @@ namespace osgParticle
virtual osg::BoundingBox computeBound() const; virtual osg::BoundingBox computeBound() const;
osgDB::ReadWriteMutex* getReadWriteMutex() const { return &_readWriteMutex; } OpenThreads::ReadWriteMutex* getReadWriteMutex() const { return &_readWriteMutex; }
protected: protected:
@ -205,7 +205,7 @@ namespace osgParticle
int _detail; int _detail;
mutable int _draw_count; mutable int _draw_count;
mutable osgDB::ReadWriteMutex _readWriteMutex; mutable OpenThreads::ReadWriteMutex _readWriteMutex;
}; };

View File

@ -137,7 +137,7 @@ GraphicsContext::GraphicsContext():
_threadOfLastMakeCurrent(0) _threadOfLastMakeCurrent(0)
{ {
setThreadSafeRefUnref(true); setThreadSafeRefUnref(true);
_operationsBlock = new Block; _operationsBlock = new RefBlock;
} }
GraphicsContext::GraphicsContext(const GraphicsContext&, const osg::CopyOp&): GraphicsContext::GraphicsContext(const GraphicsContext&, const osg::CopyOp&):
@ -146,7 +146,7 @@ GraphicsContext::GraphicsContext(const GraphicsContext&, const osg::CopyOp&):
_threadOfLastMakeCurrent(0) _threadOfLastMakeCurrent(0)
{ {
setThreadSafeRefUnref(true); setThreadSafeRefUnref(true);
_operationsBlock = new Block; _operationsBlock = new RefBlock;
} }
GraphicsContext::~GraphicsContext() GraphicsContext::~GraphicsContext()

View File

@ -44,7 +44,7 @@ OperationsThread::OperationsThread():
_parent(0), _parent(0),
_done(false) _done(false)
{ {
_operationsBlock = new Block; _operationsBlock = new RefBlock;
} }
OperationsThread::~OperationsThread() OperationsThread::~OperationsThread()

View File

@ -37,8 +37,8 @@ DatabasePager::DatabasePager()
_useFrameBlock = false; _useFrameBlock = false;
_numFramesActive = 0; _numFramesActive = 0;
_frameNumber = 0; _frameNumber = 0;
_frameBlock = new osg::Block; _frameBlock = new osg::RefBlock;
_databasePagerThreadBlock = new osg::Block; _databasePagerThreadBlock = new osg::RefBlock;
_threadPriorityDuringFrame = THREAD_PRIORITY_MIN; _threadPriorityDuringFrame = THREAD_PRIORITY_MIN;
_threadPriorityOutwithFrame = THREAD_PRIORITY_MIN; _threadPriorityOutwithFrame = THREAD_PRIORITY_MIN;

View File

@ -9,7 +9,6 @@ CXXFILES =\
FileUtils.cpp\ FileUtils.cpp\
ReadFile.cpp\ ReadFile.cpp\
ReaderWriter.cpp\ ReaderWriter.cpp\
ReentrantMutex.cpp\
Registry.cpp\ Registry.cpp\
Version.cpp\ Version.cpp\
WriteFile.cpp\ WriteFile.cpp\

View File

@ -114,7 +114,7 @@ void ConnectedParticleSystem::reuseParticle(int particleIndex)
void ConnectedParticleSystem::drawImplementation(osg::State& state) const void ConnectedParticleSystem::drawImplementation(osg::State& state) const
{ {
osgDB::ScopedReadLock lock(_readWriteMutex); OpenThreads::ScopedReadLock lock(_readWriteMutex);
const Particle* particle = (_startParticle != Particle::INVALID_INDEX) ? &_particles[_startParticle] : 0; const Particle* particle = (_startParticle != Particle::INVALID_INDEX) ? &_particles[_startParticle] : 0;
if (!particle) return; if (!particle) return;

View File

@ -64,7 +64,7 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv)
{ {
if (nv.getFrameStamp()) if (nv.getFrameStamp())
{ {
osgDB::ScopedWriteLock lock(*(_ps->getReadWriteMutex())); OpenThreads::ScopedWriteLock lock(*(_ps->getReadWriteMutex()));
//added- 1/17/06- bgandere@nps.edu //added- 1/17/06- bgandere@nps.edu
//a check to make sure we havent updated yet this frame //a check to make sure we havent updated yet this frame

View File

@ -91,7 +91,7 @@ void osgParticle::ParticleSystem::update(double dt)
void osgParticle::ParticleSystem::drawImplementation(osg::State& state) const void osgParticle::ParticleSystem::drawImplementation(osg::State& state) const
{ {
osgDB::ScopedReadLock lock(_readWriteMutex); OpenThreads::ScopedReadLock lock(_readWriteMutex);
// update the frame count, so other objects can detect when // update the frame count, so other objects can detect when
// this particle system is culled // this particle system is culled

View File

@ -40,7 +40,7 @@ void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor& nv)
{ {
ParticleSystem* ps = i->get(); ParticleSystem* ps = i->get();
osgDB::ScopedWriteLock lock(*(ps->getReadWriteMutex())); OpenThreads::ScopedWriteLock lock(*(ps->getReadWriteMutex()));
if (!ps->isFrozen() && (ps->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !ps->getFreezeOnCull())) if (!ps->isFrozen() && (ps->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !ps->getFreezeOnCull()))
{ {

View File

@ -11,14 +11,14 @@
#include <osgDB/FileUtils> #include <osgDB/FileUtils>
#include <osgDB/Registry> #include <osgDB/Registry>
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
#include <osgDB/ReentrantMutex> #include <OpenThreads/ReentrantMutex>
#include <osgUtil/Optimizer> #include <osgUtil/Optimizer>
#include "Registry.h" #include "Registry.h"
#include "Document.h" #include "Document.h"
#include "RecordInputStream.h" #include "RecordInputStream.h"
#define SERIALIZER() OpenThreads::ScopedLock<osgDB::ReentrantMutex> lock(_serializerMutex) #define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
using namespace flt; using namespace flt;
using namespace osg; using namespace osg;
@ -279,7 +279,7 @@ class FLTReaderWriter : public ReaderWriter
protected: protected:
mutable osgDB::ReentrantMutex _serializerMutex; mutable OpenThreads::ReentrantMutex _serializerMutex;
}; };
// now register with Registry to instantiate the above // now register with Registry to instantiate the above

View File

@ -18,14 +18,14 @@
#include <osgDB/Registry> #include <osgDB/Registry>
#include <OpenThreads/ScopedLock> #include <OpenThreads/ScopedLock>
#include <osgDB/ReentrantMutex> #include <OpenThreads/ReentrantMutex>
#include "daeReader.h" #include "daeReader.h"
#include "daeWriter.h" #include "daeWriter.h"
#define EXTENSION_NAME "dae" #define EXTENSION_NAME "dae"
#define SERIALIZER() OpenThreads::ScopedLock<osgDB::ReentrantMutex> lock(_serializerMutex) #define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// OSG reader/writer plugin for the COLLADA 1.4.x ".dae" format. // OSG reader/writer plugin for the COLLADA 1.4.x ".dae" format.
@ -61,7 +61,7 @@ public:
private: private:
mutable DAE *_dae; mutable DAE *_dae;
mutable osgDB::ReentrantMutex _serializerMutex; mutable OpenThreads::ReentrantMutex _serializerMutex;
}; };

View File

@ -26,7 +26,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readObject(const std::string& f
osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{ {
// serialize all access to the OpenFlight plugin as its not thread safe by itself. // serialize all access to the OpenFlight plugin as its not thread safe by itself.
OpenThreads::ScopedLock<osgDB::ReentrantMutex> lock(_serializerMutex); OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex);
std::string ext = osgDB::getLowerCaseFileExtension(file); std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;

View File

@ -38,7 +38,7 @@
#include <osgDB/Registry> #include <osgDB/Registry>
#include <osgDB/FileNameUtils> #include <osgDB/FileNameUtils>
#include <osgDB/ReentrantMutex> #include <OpenThreads/ReentrantMutex>
namespace flt { namespace flt {
@ -59,7 +59,7 @@ public:
protected: protected:
mutable osgDB::ReentrantMutex _serializerMutex; mutable OpenThreads::ReentrantMutex _serializerMutex;
}; };

View File

@ -9,11 +9,11 @@
#include <osgDB/ImageOptions> #include <osgDB/ImageOptions>
#include <OpenThreads/ScopedLock> #include <OpenThreads/ScopedLock>
#include <osgDB/ReentrantMutex> #include <OpenThreads/ReentrantMutex>
#include <gdal_priv.h> #include <gdal_priv.h>
#define SERIALIZER() OpenThreads::ScopedLock<osgDB::ReentrantMutex> lock(_serializerMutex) #define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
// From easyrgb.com // From easyrgb.com
float Hue_2_RGB( float v1, float v2, float vH ) float Hue_2_RGB( float v1, float v2, float vH )
@ -37,13 +37,13 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
{ {
OpenThreads::ScopedLock<osgDB::ReentrantMutex> lock(_serializerMutex); OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex);
return const_cast<ReaderWriterGDAL*>(this)->local_readImage(fileName, options); return const_cast<ReaderWriterGDAL*>(this)->local_readImage(fileName, options);
} }
virtual ReadResult readHeightField(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const virtual ReadResult readHeightField(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
{ {
OpenThreads::ScopedLock<osgDB::ReentrantMutex> lock(_serializerMutex); OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex);
return const_cast<ReaderWriterGDAL*>(this)->local_readHeightField(fileName, options); return const_cast<ReaderWriterGDAL*>(this)->local_readHeightField(fileName, options);
} }
@ -729,7 +729,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
} }
} }
mutable osgDB::ReentrantMutex _serializerMutex; mutable OpenThreads::ReentrantMutex _serializerMutex;
}; };

View File

@ -16,9 +16,9 @@
#include <osgDB/FileNameUtils> #include <osgDB/FileNameUtils>
#include <OpenThreads/ScopedLock> #include <OpenThreads/ScopedLock>
#include <osgDB/ReentrantMutex> #include <OpenThreads/ReentrantMutex>
#define SERIALIZER() OpenThreads::ScopedLock<osgDB::ReentrantMutex> lock(_serializerMutex) #define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
class OSGA_Archive : public osgDB::Archive class OSGA_Archive : public osgDB::Archive
{ {
@ -93,7 +93,7 @@ class OSGA_Archive : public osgDB::Archive
protected: protected:
mutable osgDB::ReentrantMutex _serializerMutex; mutable OpenThreads::ReentrantMutex _serializerMutex;
class IndexBlock; class IndexBlock;
friend class IndexBlock; friend class IndexBlock;

View File

@ -44,7 +44,7 @@
#include <map> #include <map>
#include <OpenThreads/ScopedLock> #include <OpenThreads/ScopedLock>
#include <osgDB/ReentrantMutex> #include <OpenThreads/ReentrantMutex>
#include "TXPArchive.h" #include "TXPArchive.h"
@ -68,7 +68,7 @@ public:
if( !acceptsExtension(osgDB::getFileExtension(file) )) if( !acceptsExtension(osgDB::getFileExtension(file) ))
return ReadResult::FILE_NOT_HANDLED; return ReadResult::FILE_NOT_HANDLED;
OpenThreads::ScopedLock<osgDB::ReentrantMutex> lock(_serializerMutex); OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex);
return const_cast<ReaderWriterTXP*>(this)->local_readNode(file, options); return const_cast<ReaderWriterTXP*>(this)->local_readNode(file, options);
} }
@ -85,7 +85,7 @@ protected:
void createChildrenLocationString(const std::vector<TXPArchive::TileLocationInfo>& locs, std::string& locString) const; void createChildrenLocationString(const std::vector<TXPArchive::TileLocationInfo>& locs, std::string& locString) const;
bool extractChildrenLocations(const std::string& name, int parentLod, std::vector<TXPArchive::TileLocationInfo>& locs, int nbChild) const; bool extractChildrenLocations(const std::string& name, int parentLod, std::vector<TXPArchive::TileLocationInfo>& locs, int nbChild) const;
mutable osgDB::ReentrantMutex _serializerMutex; mutable OpenThreads::ReentrantMutex _serializerMutex;
std::map< int,osg::ref_ptr<TXPArchive> > _archives; std::map< int,osg::ref_ptr<TXPArchive> > _archives;
static int _archiveId; static int _archiveId;

View File

@ -66,9 +66,9 @@ BEGIN_OBJECT_REFLECTOR(osg::GraphicsContext)
__OpenThreads_Mutex_P1__getOperationsMutex, __OpenThreads_Mutex_P1__getOperationsMutex,
"Get the operations queue mutex. ", "Get the operations queue mutex. ",
""); "");
I_Method0(osg::Block *, getOperationsBlock, I_Method0(osg::RefBlock *, getOperationsBlock,
Properties::NON_VIRTUAL, Properties::NON_VIRTUAL,
__osg_Block_P1__getOperationsBlock, __osg_RefBlock_P1__getOperationsBlock,
"Get the operations queue block used to mark an empty queue, if you end items into the empty queu you must release this block. ", "Get the operations queue block used to mark an empty queue, if you end items into the empty queu you must release this block. ",
""); "");
I_Method0(osg::Operation *, getCurrentOperation, I_Method0(osg::Operation *, getCurrentOperation,
@ -305,8 +305,8 @@ BEGIN_OBJECT_REFLECTOR(osg::GraphicsContext)
I_SimpleProperty(osg::OperationsThread *, GraphicsThread, I_SimpleProperty(osg::OperationsThread *, GraphicsThread,
__OperationsThread_P1__getGraphicsThread, __OperationsThread_P1__getGraphicsThread,
__void__setGraphicsThread__OperationsThread_P1); __void__setGraphicsThread__OperationsThread_P1);
I_SimpleProperty(osg::Block *, OperationsBlock, I_SimpleProperty(osg::RefBlock *, OperationsBlock,
__osg_Block_P1__getOperationsBlock, __osg_RefBlock_P1__getOperationsBlock,
0); 0);
I_SimpleProperty(OpenThreads::Mutex *, OperationsMutex, I_SimpleProperty(OpenThreads::Mutex *, OperationsMutex,
__OpenThreads_Mutex_P1__getOperationsMutex, __OpenThreads_Mutex_P1__getOperationsMutex,

View File

@ -41,33 +41,6 @@ BEGIN_OBJECT_REFLECTOR(osg::BarrierOperation)
I_PublicMemberProperty(osg::BarrierOperation::PreBlockOp, _preBlockOp); I_PublicMemberProperty(osg::BarrierOperation::PreBlockOp, _preBlockOp);
END_REFLECTOR END_REFLECTOR
BEGIN_OBJECT_REFLECTOR(osg::Block)
I_VirtualBaseType(osg::Referenced);
I_Constructor0(____Block,
"",
"");
I_Method0(void, block,
Properties::NON_VIRTUAL,
__void__block,
"",
"");
I_Method0(void, release,
Properties::NON_VIRTUAL,
__void__release,
"",
"");
I_Method0(void, reset,
Properties::NON_VIRTUAL,
__void__reset,
"",
"");
I_Method1(void, set, IN, bool, doRelease,
Properties::NON_VIRTUAL,
__void__set__bool,
"",
"");
END_REFLECTOR
BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Operation) BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Operation)
I_VirtualBaseType(osg::Referenced); I_VirtualBaseType(osg::Referenced);
I_Constructor2(IN, const std::string &, name, IN, bool, keep, I_Constructor2(IN, const std::string &, name, IN, bool, keep,
@ -185,16 +158,23 @@ BEGIN_OBJECT_REFLECTOR(osg::OperationsThread)
__void__setParent__Object_P1); __void__setParent__Object_P1);
END_REFLECTOR END_REFLECTOR
BEGIN_OBJECT_REFLECTOR(osg::RefBlock)
I_VirtualBaseType(osg::Referenced);
I_Constructor0(____RefBlock,
"",
"");
END_REFLECTOR
BEGIN_OBJECT_REFLECTOR(osg::ReleaseContext_Block_MakeCurrentOperation) BEGIN_OBJECT_REFLECTOR(osg::ReleaseContext_Block_MakeCurrentOperation)
I_BaseType(osg::Operation); I_BaseType(osg::Operation);
I_BaseType(osg::Block); I_BaseType(osg::RefBlock);
I_Constructor0(____ReleaseContext_Block_MakeCurrentOperation, I_Constructor0(____ReleaseContext_Block_MakeCurrentOperation,
"", "",
""); "");
I_Method0(void, release, I_Method0(void, release,
Properties::VIRTUAL, Properties::VIRTUAL,
__void__release, __void__release,
"", "if this operation is a barrier then release it. ",
""); "");
END_REFLECTOR END_REFLECTOR

View File

@ -108,9 +108,9 @@ BEGIN_OBJECT_REFLECTOR(osgDB::DatabasePager)
__bool__getUseFrameBlock, __bool__getUseFrameBlock,
"Get the whether UseFrameBlock is on or off. ", "Get the whether UseFrameBlock is on or off. ",
""); "");
I_Method0(osg::Block *, getFrameBlock, I_Method0(osg::RefBlock *, getFrameBlock,
Properties::NON_VIRTUAL, Properties::NON_VIRTUAL,
__osg_Block_P1__getFrameBlock, __osg_RefBlock_P1__getFrameBlock,
"", "",
""); "");
I_Method1(void, setThreadPriorityDuringFrame, IN, osgDB::DatabasePager::ThreadPriority, duringFrame, I_Method1(void, setThreadPriorityDuringFrame, IN, osgDB::DatabasePager::ThreadPriority, duringFrame,
@ -311,8 +311,8 @@ BEGIN_OBJECT_REFLECTOR(osgDB::DatabasePager)
I_SimpleProperty(unsigned int, FileRequestListSize, I_SimpleProperty(unsigned int, FileRequestListSize,
__unsigned_int__getFileRequestListSize, __unsigned_int__getFileRequestListSize,
0); 0);
I_SimpleProperty(osg::Block *, FrameBlock, I_SimpleProperty(osg::RefBlock *, FrameBlock,
__osg_Block_P1__getFrameBlock, __osg_RefBlock_P1__getFrameBlock,
0); 0);
I_SimpleProperty(unsigned int, MaximumNumOfObjectsToCompilePerFrame, I_SimpleProperty(unsigned int, MaximumNumOfObjectsToCompilePerFrame,
__unsigned_int__getMaximumNumOfObjectsToCompilePerFrame, __unsigned_int__getMaximumNumOfObjectsToCompilePerFrame,

View File

@ -15,7 +15,6 @@ CXXFILES =\
Output.cpp\ Output.cpp\
ParameterOutput.cpp\ ParameterOutput.cpp\
ReaderWriter.cpp\ ReaderWriter.cpp\
ReentrantMutex.cpp\
Registry.cpp\ Registry.cpp\
SharedStateManager.cpp\ SharedStateManager.cpp\

View File

@ -1,85 +0,0 @@
// ***************************************************************************
//
// Generated automatically by genwrapper.
// Please DO NOT EDIT this file!
//
// ***************************************************************************
#include <osgIntrospection/ReflectionMacros>
#include <osgIntrospection/TypedMethodInfo>
#include <osgIntrospection/StaticMethodInfo>
#include <osgIntrospection/Attributes>
#include <osgDB/ReentrantMutex>
// Must undefine IN and OUT macros defined in Windows headers
#ifdef IN
#undef IN
#endif
#ifdef OUT
#undef OUT
#endif
BEGIN_OBJECT_REFLECTOR(osgDB::ReadWriteMutex)
I_Constructor0(____ReadWriteMutex,
"",
"");
I_Method0(int, readLock,
Properties::VIRTUAL,
__int__readLock,
"",
"");
I_Method0(int, readUnlock,
Properties::VIRTUAL,
__int__readUnlock,
"",
"");
I_Method0(int, writeLock,
Properties::VIRTUAL,
__int__writeLock,
"",
"");
I_Method0(int, writeUnlock,
Properties::VIRTUAL,
__int__writeUnlock,
"",
"");
END_REFLECTOR
BEGIN_OBJECT_REFLECTOR(osgDB::ReentrantMutex)
I_Constructor0(____ReentrantMutex,
"",
"");
I_Method0(int, lock,
Properties::VIRTUAL,
__int__lock,
"",
"");
I_Method0(int, unlock,
Properties::VIRTUAL,
__int__unlock,
"",
"");
I_Method0(int, trylock,
Properties::VIRTUAL,
__int__trylock,
"",
"");
END_REFLECTOR
BEGIN_VALUE_REFLECTOR(osgDB::ScopedReadLock)
I_Constructor1(IN, osgDB::ReadWriteMutex &, mutex,
Properties::NON_EXPLICIT,
____ScopedReadLock__ReadWriteMutex_R1,
"",
"");
END_REFLECTOR
BEGIN_VALUE_REFLECTOR(osgDB::ScopedWriteLock)
I_Constructor1(IN, osgDB::ReadWriteMutex &, mutex,
Properties::NON_EXPLICIT,
____ScopedWriteLock__ReadWriteMutex_R1,
"",
"");
END_REFLECTOR

View File

@ -15,7 +15,6 @@
#include <osg/Object> #include <osg/Object>
#include <osg/State> #include <osg/State>
#include <osg/Vec3> #include <osg/Vec3>
#include <osgDB/ReentrantMutex>
#include <osgParticle/Particle> #include <osgParticle/Particle>
#include <osgParticle/ParticleSystem> #include <osgParticle/ParticleSystem>
@ -231,9 +230,9 @@ BEGIN_OBJECT_REFLECTOR(osgParticle::ParticleSystem)
__osg_BoundingBox__computeBound, __osg_BoundingBox__computeBound,
"Compute the bounding box around Drawables's geometry. ", "Compute the bounding box around Drawables's geometry. ",
""); "");
I_Method0(osgDB::ReadWriteMutex *, getReadWriteMutex, I_Method0(OpenThreads::ReadWriteMutex *, getReadWriteMutex,
Properties::NON_VIRTUAL, Properties::NON_VIRTUAL,
__osgDB_ReadWriteMutex_P1__getReadWriteMutex, __OpenThreads_ReadWriteMutex_P1__getReadWriteMutex,
"", "",
""); "");
I_SimpleProperty(const osg::Vec3 &, AlignVectorX, I_SimpleProperty(const osg::Vec3 &, AlignVectorX,
@ -266,8 +265,8 @@ BEGIN_OBJECT_REFLECTOR(osgParticle::ParticleSystem)
I_SimpleProperty(osgParticle::ParticleSystem::Alignment, ParticleAlignment, I_SimpleProperty(osgParticle::ParticleSystem::Alignment, ParticleAlignment,
__Alignment__getParticleAlignment, __Alignment__getParticleAlignment,
__void__setParticleAlignment__Alignment); __void__setParticleAlignment__Alignment);
I_SimpleProperty(osgDB::ReadWriteMutex *, ReadWriteMutex, I_SimpleProperty(OpenThreads::ReadWriteMutex *, ReadWriteMutex,
__osgDB_ReadWriteMutex_P1__getReadWriteMutex, __OpenThreads_ReadWriteMutex_P1__getReadWriteMutex,
0); 0);
END_REFLECTOR END_REFLECTOR