Merge branch 'foo' into next
This commit is contained in:
@@ -20,6 +20,7 @@ props_test_LDADD = \
|
|||||||
$(top_builddir)/simgear/xml/libsgxml.a \
|
$(top_builddir)/simgear/xml/libsgxml.a \
|
||||||
$(top_builddir)/simgear/misc/libsgmisc.a \
|
$(top_builddir)/simgear/misc/libsgmisc.a \
|
||||||
$(top_builddir)/simgear/debug/libsgdebug.a \
|
$(top_builddir)/simgear/debug/libsgdebug.a \
|
||||||
$(top_builddir)/simgear/structure/libsgstructure.a
|
$(top_builddir)/simgear/structure/libsgstructure.a \
|
||||||
|
-lOpenThreads
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)
|
INCLUDES = -I$(top_srcdir)
|
||||||
|
|||||||
@@ -31,9 +31,10 @@
|
|||||||
#include <osg/PointSprite>
|
#include <osg/PointSprite>
|
||||||
#include <osg/Texture>
|
#include <osg/Texture>
|
||||||
|
|
||||||
|
#include <OpenThreads/Mutex>
|
||||||
|
#include <OpenThreads/ScopedLock>
|
||||||
|
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
#include <simgear/threads/SGThread.hxx>
|
|
||||||
#include <simgear/threads/SGGuard.hxx>
|
|
||||||
|
|
||||||
SGSceneFeatures::SGSceneFeatures() :
|
SGSceneFeatures::SGSceneFeatures() :
|
||||||
_textureCompression(UseARBCompression),
|
_textureCompression(UseARBCompression),
|
||||||
@@ -44,14 +45,14 @@ SGSceneFeatures::SGSceneFeatures() :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static SGMutex mutexSGSceneFeatures_instance;
|
static OpenThreads::Mutex mutexSGSceneFeatures_instance;
|
||||||
SGSceneFeatures*
|
SGSceneFeatures*
|
||||||
SGSceneFeatures::instance()
|
SGSceneFeatures::instance()
|
||||||
{
|
{
|
||||||
static SGSharedPtr<SGSceneFeatures> sceneFeatures;
|
static SGSharedPtr<SGSceneFeatures> sceneFeatures;
|
||||||
if (sceneFeatures)
|
if (sceneFeatures)
|
||||||
return sceneFeatures;
|
return sceneFeatures;
|
||||||
SGGuard<SGMutex> guard(mutexSGSceneFeatures_instance);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutexSGSceneFeatures_instance);
|
||||||
if (sceneFeatures)
|
if (sceneFeatures)
|
||||||
return sceneFeatures;
|
return sceneFeatures;
|
||||||
sceneFeatures = new SGSceneFeatures;
|
sceneFeatures = new SGSceneFeatures;
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
#ifndef SG_SCENE_FEATURES_HXX
|
#ifndef SG_SCENE_FEATURES_HXX
|
||||||
#define SG_SCENE_FEATURES_HXX
|
#define SG_SCENE_FEATURES_HXX
|
||||||
|
|
||||||
|
#include <OpenThreads/Mutex>
|
||||||
|
|
||||||
#include <simgear/structure/SGReferenced.hxx>
|
#include <simgear/structure/SGReferenced.hxx>
|
||||||
|
|
||||||
namespace osg { class Texture; }
|
namespace osg { class Texture; }
|
||||||
@@ -94,6 +96,8 @@ private:
|
|||||||
bool _pointSpriteLights;
|
bool _pointSpriteLights;
|
||||||
bool _distanceAttenuationLights;
|
bool _distanceAttenuationLights;
|
||||||
int _textureFilter;
|
int _textureFilter;
|
||||||
|
|
||||||
|
static OpenThreads::Mutex _instanceMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ openal_test2_LDADD = \
|
|||||||
$(top_builddir)/simgear/debug/libsgdebug.a \
|
$(top_builddir)/simgear/debug/libsgdebug.a \
|
||||||
$(top_builddir)/simgear/misc/libsgmisc.a \
|
$(top_builddir)/simgear/misc/libsgmisc.a \
|
||||||
$(top_builddir)/simgear/structure/libsgstructure.a \
|
$(top_builddir)/simgear/structure/libsgstructure.a \
|
||||||
$(openal_LIBS)
|
$(openal_LIBS) \
|
||||||
|
-lOpenThreads
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir) -DSRC_DIR=\"$(top_srcdir)/simgear/sound\"
|
INCLUDES = -I$(top_srcdir) -DSRC_DIR=\"$(top_srcdir)/simgear/sound\"
|
||||||
|
|||||||
@@ -20,8 +20,13 @@
|
|||||||
|
|
||||||
#ifndef SGReferenced_HXX
|
#ifndef SGReferenced_HXX
|
||||||
#define SGReferenced_HXX
|
#define SGReferenced_HXX
|
||||||
|
#define USE_OPENTHREADS_ATOMIC
|
||||||
|
|
||||||
|
#ifndef USE_OPENTHREADS_ATOMIC
|
||||||
#include "SGAtomic.hxx"
|
#include "SGAtomic.hxx"
|
||||||
|
#else
|
||||||
|
#include <OpenThreads/Atomic>
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Base class for all reference counted SimGear objects
|
/// Base class for all reference counted SimGear objects
|
||||||
/// Classes derived from this one are meant to be managed with
|
/// Classes derived from this one are meant to be managed with
|
||||||
@@ -49,7 +54,11 @@ public:
|
|||||||
{ if (ref) return 1u < ref->_refcount; else return false; }
|
{ if (ref) return 1u < ref->_refcount; else return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifndef USE_OPENTHREADS_ATOMIC
|
||||||
mutable SGAtomic _refcount;
|
mutable SGAtomic _refcount;
|
||||||
|
#else
|
||||||
|
mutable OpenThreads::Atomic _refcount;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,8 +6,9 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <simgear/props/props_io.hxx>
|
#include <simgear/props/props_io.hxx>
|
||||||
#include <simgear/threads/SGThread.hxx>
|
|
||||||
#include <simgear/threads/SGGuard.hxx>
|
#include <OpenThreads/Mutex>
|
||||||
|
#include <OpenThreads/ScopedLock>
|
||||||
|
|
||||||
#include "commands.hxx"
|
#include "commands.hxx"
|
||||||
|
|
||||||
@@ -28,6 +29,8 @@ SGCommandMgr::~SGCommandMgr ()
|
|||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OpenThreads::Mutex SGCommandMgr::_instanceMutex;
|
||||||
|
|
||||||
SGCommandMgr*
|
SGCommandMgr*
|
||||||
SGCommandMgr::instance()
|
SGCommandMgr::instance()
|
||||||
{
|
{
|
||||||
@@ -35,8 +38,7 @@ SGCommandMgr::instance()
|
|||||||
if (mgr.get())
|
if (mgr.get())
|
||||||
return mgr.get();
|
return mgr.get();
|
||||||
|
|
||||||
static SGMutex lock;
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_instanceMutex);
|
||||||
SGGuard<SGMutex> guard(lock);
|
|
||||||
if (mgr.get())
|
if (mgr.get())
|
||||||
return mgr.get();
|
return mgr.get();
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <OpenThreads/Mutex>
|
||||||
|
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
@@ -109,6 +111,8 @@ private:
|
|||||||
typedef map<string,command_t> command_map;
|
typedef map<string,command_t> command_map;
|
||||||
command_map _commands;
|
command_map _commands;
|
||||||
|
|
||||||
|
static OpenThreads::Mutex _instanceMutex;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __COMMANDS_HXX
|
#endif // __COMMANDS_HXX
|
||||||
|
|||||||
+17
-16
@@ -5,8 +5,9 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include "SGThread.hxx"
|
#include <OpenThreads/Mutex>
|
||||||
#include "SGGuard.hxx"
|
#include <OpenThreads/ScopedLock>
|
||||||
|
#include <OpenThreads/Condition>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SGQueue defines an interface for a FIFO.
|
* SGQueue defines an interface for a FIFO.
|
||||||
@@ -73,7 +74,7 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* A simple thread safe queue. All access functions are guarded with a mutex.
|
* A simple thread safe queue. All access functions are guarded with a mutex.
|
||||||
*/
|
*/
|
||||||
template<class T, class SGLOCK=SGMutex>
|
template<class T, class SGLOCK=OpenThreads::Mutex>
|
||||||
class SGLockedQueue : public SGQueue<T>
|
class SGLockedQueue : public SGQueue<T>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -94,7 +95,7 @@ public:
|
|||||||
* @return bool True if queue is empty, otherwisr false.
|
* @return bool True if queue is empty, otherwisr false.
|
||||||
*/
|
*/
|
||||||
virtual bool empty() {
|
virtual bool empty() {
|
||||||
SGGuard<SGLOCK> g(mutex);
|
OpenThreads::ScopedLock<SGLOCK> g(mutex);
|
||||||
return this->fifo.empty();
|
return this->fifo.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ public:
|
|||||||
* @param T object to add.
|
* @param T object to add.
|
||||||
*/
|
*/
|
||||||
virtual void push( const T& item ) {
|
virtual void push( const T& item ) {
|
||||||
SGGuard<SGLOCK> g(mutex);
|
OpenThreads::ScopedLock<SGLOCK> g(mutex);
|
||||||
this->fifo.push( item );
|
this->fifo.push( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ public:
|
|||||||
* @return T next available object.
|
* @return T next available object.
|
||||||
*/
|
*/
|
||||||
virtual T front() {
|
virtual T front() {
|
||||||
SGGuard<SGLOCK> g(mutex);
|
OpenThreads::ScopedLock<SGLOCK> g(mutex);
|
||||||
assert( ! this->fifo.empty() );
|
assert( ! this->fifo.empty() );
|
||||||
T item = this->fifo.front();
|
T item = this->fifo.front();
|
||||||
return item;
|
return item;
|
||||||
@@ -126,7 +127,7 @@ public:
|
|||||||
* @return T next available object.
|
* @return T next available object.
|
||||||
*/
|
*/
|
||||||
virtual T pop() {
|
virtual T pop() {
|
||||||
SGGuard<SGLOCK> g(mutex);
|
OpenThreads::ScopedLock<SGLOCK> g(mutex);
|
||||||
//if (fifo.empty()) throw NoSuchElementException();
|
//if (fifo.empty()) throw NoSuchElementException();
|
||||||
assert( ! this->fifo.empty() );
|
assert( ! this->fifo.empty() );
|
||||||
// if (fifo.empty())
|
// if (fifo.empty())
|
||||||
@@ -145,7 +146,7 @@ public:
|
|||||||
* @return size_t size of queue.
|
* @return size_t size of queue.
|
||||||
*/
|
*/
|
||||||
virtual size_t size() {
|
virtual size_t size() {
|
||||||
SGGuard<SGLOCK> g(mutex);
|
OpenThreads::ScopedLock<SGLOCK> g(mutex);
|
||||||
return this->fifo.size();
|
return this->fifo.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +185,7 @@ public:
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual bool empty() {
|
virtual bool empty() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> g(mutex);
|
||||||
return this->fifo.empty();
|
return this->fifo.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +195,7 @@ public:
|
|||||||
* @param T object to add.
|
* @param T object to add.
|
||||||
*/
|
*/
|
||||||
virtual void push( const T& item ) {
|
virtual void push( const T& item ) {
|
||||||
SGGuard<SGMutex> g(mutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> g(mutex);
|
||||||
this->fifo.push( item );
|
this->fifo.push( item );
|
||||||
not_empty.signal();
|
not_empty.signal();
|
||||||
}
|
}
|
||||||
@@ -206,7 +207,7 @@ public:
|
|||||||
* @return T next available object.
|
* @return T next available object.
|
||||||
*/
|
*/
|
||||||
virtual T front() {
|
virtual T front() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> g(mutex);
|
||||||
|
|
||||||
assert(this->fifo.empty() != true);
|
assert(this->fifo.empty() != true);
|
||||||
//if (fifo.empty()) throw ??
|
//if (fifo.empty()) throw ??
|
||||||
@@ -222,10 +223,10 @@ public:
|
|||||||
* @return T next available object.
|
* @return T next available object.
|
||||||
*/
|
*/
|
||||||
virtual T pop() {
|
virtual T pop() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> g(mutex);
|
||||||
|
|
||||||
while (this->fifo.empty())
|
while (this->fifo.empty())
|
||||||
not_empty.wait(mutex);
|
not_empty.wait(&mutex);
|
||||||
|
|
||||||
assert(this->fifo.empty() != true);
|
assert(this->fifo.empty() != true);
|
||||||
//if (fifo.empty()) throw ??
|
//if (fifo.empty()) throw ??
|
||||||
@@ -241,7 +242,7 @@ public:
|
|||||||
* @return size_t size of queue.
|
* @return size_t size of queue.
|
||||||
*/
|
*/
|
||||||
virtual size_t size() {
|
virtual size_t size() {
|
||||||
SGGuard<SGMutex> g(mutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> g(mutex);
|
||||||
return this->fifo.size();
|
return this->fifo.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,12 +251,12 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Mutex to serialise access.
|
* Mutex to serialise access.
|
||||||
*/
|
*/
|
||||||
SGMutex mutex;
|
OpenThreads::Mutex mutex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Condition to signal when queue not empty.
|
* Condition to signal when queue not empty.
|
||||||
*/
|
*/
|
||||||
SGPthreadCond not_empty;
|
OpenThreads::Condition not_empty;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Prevent copying.
|
// Prevent copying.
|
||||||
|
|||||||
Reference in New Issue
Block a user