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

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

View File

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

View File

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

View File

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

View File

@@ -114,7 +114,7 @@ void ConnectedParticleSystem::reuseParticle(int particleIndex)
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;
if (!particle) return;

View File

@@ -64,7 +64,7 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv)
{
if (nv.getFrameStamp())
{
osgDB::ScopedWriteLock lock(*(_ps->getReadWriteMutex()));
OpenThreads::ScopedWriteLock lock(*(_ps->getReadWriteMutex()));
//added- 1/17/06- bgandere@nps.edu
//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
{
osgDB::ScopedReadLock lock(_readWriteMutex);
OpenThreads::ScopedReadLock lock(_readWriteMutex);
// update the frame count, so other objects can detect when
// this particle system is culled

View File

@@ -40,7 +40,7 @@ void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor& nv)
{
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()))
{

View File

@@ -11,14 +11,14 @@
#include <osgDB/FileUtils>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/ReentrantMutex>
#include <OpenThreads/ReentrantMutex>
#include <osgUtil/Optimizer>
#include "Registry.h"
#include "Document.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 osg;
@@ -279,7 +279,7 @@ class FLTReaderWriter : public ReaderWriter
protected:
mutable osgDB::ReentrantMutex _serializerMutex;
mutable OpenThreads::ReentrantMutex _serializerMutex;
};
// now register with Registry to instantiate the above

View File

@@ -18,14 +18,14 @@
#include <osgDB/Registry>
#include <OpenThreads/ScopedLock>
#include <osgDB/ReentrantMutex>
#include <OpenThreads/ReentrantMutex>
#include "daeReader.h"
#include "daeWriter.h"
#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.
@@ -61,7 +61,7 @@ public:
private:
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
{
// 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);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;

View File

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

View File

@@ -9,11 +9,11 @@
#include <osgDB/ImageOptions>
#include <OpenThreads/ScopedLock>
#include <osgDB/ReentrantMutex>
#include <OpenThreads/ReentrantMutex>
#include <gdal_priv.h>
#define SERIALIZER() OpenThreads::ScopedLock<osgDB::ReentrantMutex> lock(_serializerMutex)
#define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
// From easyrgb.com
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
{
OpenThreads::ScopedLock<osgDB::ReentrantMutex> lock(_serializerMutex);
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex);
return const_cast<ReaderWriterGDAL*>(this)->local_readImage(fileName, options);
}
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);
}
@@ -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 <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
{
@@ -93,7 +93,7 @@ class OSGA_Archive : public osgDB::Archive
protected:
mutable osgDB::ReentrantMutex _serializerMutex;
mutable OpenThreads::ReentrantMutex _serializerMutex;
class IndexBlock;
friend class IndexBlock;

View File

@@ -44,7 +44,7 @@
#include <map>
#include <OpenThreads/ScopedLock>
#include <osgDB/ReentrantMutex>
#include <OpenThreads/ReentrantMutex>
#include "TXPArchive.h"
@@ -68,7 +68,7 @@ public:
if( !acceptsExtension(osgDB::getFileExtension(file) ))
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);
}
@@ -85,7 +85,7 @@ protected:
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;
mutable osgDB::ReentrantMutex _serializerMutex;
mutable OpenThreads::ReentrantMutex _serializerMutex;
std::map< int,osg::ref_ptr<TXPArchive> > _archives;
static int _archiveId;

View File

@@ -66,9 +66,9 @@ BEGIN_OBJECT_REFLECTOR(osg::GraphicsContext)
__OpenThreads_Mutex_P1__getOperationsMutex,
"Get the operations queue mutex. ",
"");
I_Method0(osg::Block *, getOperationsBlock,
I_Method0(osg::RefBlock *, getOperationsBlock,
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. ",
"");
I_Method0(osg::Operation *, getCurrentOperation,
@@ -305,8 +305,8 @@ BEGIN_OBJECT_REFLECTOR(osg::GraphicsContext)
I_SimpleProperty(osg::OperationsThread *, GraphicsThread,
__OperationsThread_P1__getGraphicsThread,
__void__setGraphicsThread__OperationsThread_P1);
I_SimpleProperty(osg::Block *, OperationsBlock,
__osg_Block_P1__getOperationsBlock,
I_SimpleProperty(osg::RefBlock *, OperationsBlock,
__osg_RefBlock_P1__getOperationsBlock,
0);
I_SimpleProperty(OpenThreads::Mutex *, OperationsMutex,
__OpenThreads_Mutex_P1__getOperationsMutex,

View File

@@ -41,33 +41,6 @@ BEGIN_OBJECT_REFLECTOR(osg::BarrierOperation)
I_PublicMemberProperty(osg::BarrierOperation::PreBlockOp, _preBlockOp);
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)
I_VirtualBaseType(osg::Referenced);
I_Constructor2(IN, const std::string &, name, IN, bool, keep,
@@ -185,16 +158,23 @@ BEGIN_OBJECT_REFLECTOR(osg::OperationsThread)
__void__setParent__Object_P1);
END_REFLECTOR
BEGIN_OBJECT_REFLECTOR(osg::RefBlock)
I_VirtualBaseType(osg::Referenced);
I_Constructor0(____RefBlock,
"",
"");
END_REFLECTOR
BEGIN_OBJECT_REFLECTOR(osg::ReleaseContext_Block_MakeCurrentOperation)
I_BaseType(osg::Operation);
I_BaseType(osg::Block);
I_BaseType(osg::RefBlock);
I_Constructor0(____ReleaseContext_Block_MakeCurrentOperation,
"",
"");
I_Method0(void, release,
Properties::VIRTUAL,
__void__release,
"",
"if this operation is a barrier then release it. ",
"");
END_REFLECTOR

View File

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

View File

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