Merged from OSG-2.8 branch changes to the use of ReadWriteMutex to Mutex in osgParticle::ParticleSystem.
svn command: svn merge -r 9725:9726 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/branches/OpenSceneGraph-2.8
This commit is contained in:
@@ -30,7 +30,17 @@
|
||||
#include <osg/Vec3>
|
||||
#include <osg/BoundingBox>
|
||||
|
||||
#include <OpenThreads/ReadWriteMutex>
|
||||
// 9th Febrary 2009, disabled the use of ReadWriteMutex as it looks like this
|
||||
// is introducing threading problems due to threading problems in OpenThreads::ReadWriteMutex.
|
||||
// #define OSGPARTICLE_USE_ReadWriteMutex
|
||||
|
||||
#ifdef OSGPARTICLE_USE_ReadWriteMutex
|
||||
#include <OpenThreads/ReadWriteMutex>
|
||||
#else
|
||||
#include <OpenThreads/Mutex>
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#endif
|
||||
|
||||
|
||||
namespace osgParticle
|
||||
{
|
||||
@@ -182,7 +192,17 @@ namespace osgParticle
|
||||
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
|
||||
OpenThreads::ReadWriteMutex* getReadWriteMutex() const { return &_readWriteMutex; }
|
||||
#ifdef OSGPARTICLE_USE_ReadWriteMutex
|
||||
typedef OpenThreads::ReadWriteMutex ReadWriterMutex;
|
||||
typedef OpenThreads::ScopedReadLock ScopedReadLock;
|
||||
typedef OpenThreads::ScopedWriteLock ScopedWriteLock;
|
||||
#else
|
||||
typedef OpenThreads::Mutex ReadWriterMutex;
|
||||
typedef OpenThreads::ScopedLock<OpenThreads::Mutex> ScopedReadLock;
|
||||
typedef OpenThreads::ScopedLock<OpenThreads::Mutex> ScopedWriteLock;
|
||||
#endif
|
||||
|
||||
ReadWriterMutex* getReadWriteMutex() const { return &_readWriteMutex; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -222,8 +242,7 @@ namespace osgParticle
|
||||
int _detail;
|
||||
mutable int _draw_count;
|
||||
|
||||
mutable OpenThreads::ReadWriteMutex _readWriteMutex;
|
||||
|
||||
mutable ReadWriterMutex _readWriteMutex;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
@@ -116,7 +116,7 @@ void ConnectedParticleSystem::drawImplementation(osg::RenderInfo& renderInfo) co
|
||||
{
|
||||
osg::State& state = *renderInfo.getState();
|
||||
|
||||
OpenThreads::ScopedReadLock lock(_readWriteMutex);
|
||||
ScopedReadLock lock(_readWriteMutex);
|
||||
|
||||
const Particle* particle = (_startParticle != Particle::INVALID_INDEX) ? &_particles[_startParticle] : 0;
|
||||
if (!particle) return;
|
||||
|
||||
@@ -64,7 +64,7 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (nv.getFrameStamp())
|
||||
{
|
||||
OpenThreads::ScopedWriteLock lock(*(_ps->getReadWriteMutex()));
|
||||
ParticleSystem::ScopedWriteLock lock(*(_ps->getReadWriteMutex()));
|
||||
|
||||
//added- 1/17/06- bgandere@nps.edu
|
||||
//a check to make sure we havent updated yet this frame
|
||||
|
||||
@@ -96,7 +96,7 @@ void osgParticle::ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo
|
||||
{
|
||||
osg::State& state = *renderInfo.getState();
|
||||
|
||||
OpenThreads::ScopedReadLock lock(_readWriteMutex);
|
||||
ScopedReadLock lock(_readWriteMutex);
|
||||
|
||||
// update the frame count, so other objects can detect when
|
||||
// this particle system is culled
|
||||
|
||||
@@ -40,7 +40,7 @@ void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
ParticleSystem* ps = i->get();
|
||||
|
||||
OpenThreads::ScopedWriteLock lock(*(ps->getReadWriteMutex()));
|
||||
ParticleSystem::ScopedWriteLock lock(*(ps->getReadWriteMutex()));
|
||||
|
||||
if (!ps->isFrozen() && (ps->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !ps->getFreezeOnCull()))
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <osgIntrospection/StaticMethodInfo>
|
||||
#include <osgIntrospection/Attributes>
|
||||
|
||||
#include <OpenThreads/ReadWriteMutex>
|
||||
#include <OpenThreads/Mutex>
|
||||
#include <osg/BoundingBox>
|
||||
#include <osg/CopyOp>
|
||||
#include <osg/Object>
|
||||
@@ -27,6 +27,12 @@
|
||||
#undef OUT
|
||||
#endif
|
||||
|
||||
TYPE_NAME_ALIAS(OpenThreads::Mutex, osgParticle::ParticleSystem::ReadWriterMutex)
|
||||
|
||||
TYPE_NAME_ALIAS(OpenThreads::ScopedLock< OpenThreads::Mutex >, osgParticle::ParticleSystem::ScopedReadLock)
|
||||
|
||||
TYPE_NAME_ALIAS(OpenThreads::ScopedLock< OpenThreads::Mutex >, osgParticle::ParticleSystem::ScopedWriteLock)
|
||||
|
||||
BEGIN_ENUM_REFLECTOR(osgParticle::ParticleSystem::Alignment)
|
||||
I_DeclaringFile("osgParticle/ParticleSystem");
|
||||
I_EnumLabel(osgParticle::ParticleSystem::BILLBOARD);
|
||||
@@ -249,9 +255,9 @@ BEGIN_OBJECT_REFLECTOR(osgParticle::ParticleSystem)
|
||||
__osg_BoundingBox__computeBound,
|
||||
"Compute the bounding box around Drawables's geometry. ",
|
||||
"");
|
||||
I_Method0(OpenThreads::ReadWriteMutex *, getReadWriteMutex,
|
||||
I_Method0(osgParticle::ParticleSystem::ReadWriterMutex *, getReadWriteMutex,
|
||||
Properties::NON_VIRTUAL,
|
||||
__OpenThreads_ReadWriteMutex_P1__getReadWriteMutex,
|
||||
__ReadWriterMutex_P1__getReadWriteMutex,
|
||||
"",
|
||||
"");
|
||||
I_ProtectedMethod2(void, update_bounds, IN, const osg::Vec3 &, p, IN, float, r,
|
||||
@@ -299,8 +305,17 @@ BEGIN_OBJECT_REFLECTOR(osgParticle::ParticleSystem)
|
||||
I_SimpleProperty(osgParticle::ParticleSystem::ParticleScaleReferenceFrame, ParticleScaleReferenceFrame,
|
||||
__ParticleScaleReferenceFrame__getParticleScaleReferenceFrame,
|
||||
__void__setParticleScaleReferenceFrame__ParticleScaleReferenceFrame);
|
||||
I_SimpleProperty(OpenThreads::ReadWriteMutex *, ReadWriteMutex,
|
||||
__OpenThreads_ReadWriteMutex_P1__getReadWriteMutex,
|
||||
I_SimpleProperty(osgParticle::ParticleSystem::ReadWriterMutex *, ReadWriteMutex,
|
||||
__ReadWriterMutex_P1__getReadWriteMutex,
|
||||
0);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_VALUE_REFLECTOR(OpenThreads::ScopedLock< OpenThreads::Mutex >)
|
||||
I_DeclaringFile("OpenThreads/ScopedLock");
|
||||
I_Constructor1(IN, OpenThreads::Mutex &, m,
|
||||
Properties::EXPLICIT,
|
||||
____ScopedLock__M_R1,
|
||||
"",
|
||||
"");
|
||||
END_REFLECTOR
|
||||
|
||||
|
||||
Reference in New Issue
Block a user