]> git.mxchange.org Git - simgear.git/commitdiff
Commit Benoit Laniel's patch which converts more SimGear pieces to use
authorjmt <jmt>
Thu, 15 Jan 2009 14:34:33 +0000 (14:34 +0000)
committerTim Moore <timoore@redhat.com>
Thu, 15 Jan 2009 21:49:00 +0000 (22:49 +0100)
OpenThreads primitives directly.

simgear/scene/util/SGSceneFeatures.cxx
simgear/scene/util/SGSceneFeatures.hxx
simgear/threads/SGQueue.hxx

index 71edb2ebbda525cdcb9aab551e77fed719508da6..4367e453926ddbde2f390af6662c1300ebde3644 100644 (file)
 #include <osg/PointSprite>
 #include <osg/Texture>
 
+#include <OpenThreads/Mutex>
+#include <OpenThreads/ScopedLock>
+
 #include <simgear/structure/SGSharedPtr.hxx>
-#include <simgear/threads/SGThread.hxx>
-#include <simgear/threads/SGGuard.hxx>
 
 SGSceneFeatures::SGSceneFeatures() :
   _textureCompression(UseARBCompression),
@@ -44,14 +45,14 @@ SGSceneFeatures::SGSceneFeatures() :
 {
 }
 
-static SGMutex mutexSGSceneFeatures_instance;
+static OpenThreads::Mutex mutexSGSceneFeatures_instance;
 SGSceneFeatures*
 SGSceneFeatures::instance()
 {
   static SGSharedPtr<SGSceneFeatures> sceneFeatures;
   if (sceneFeatures)
     return sceneFeatures;
-  SGGuard<SGMutex> guard(mutexSGSceneFeatures_instance);
+  OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutexSGSceneFeatures_instance);
   if (sceneFeatures)
     return sceneFeatures;
   sceneFeatures = new SGSceneFeatures;
index 458633ffd4d6e599a1131da6c2b67de47474544a..ced6c919d57e843848b0f82d46608ec3a81f61b5 100644 (file)
@@ -22,6 +22,8 @@
 #ifndef SG_SCENE_FEATURES_HXX
 #define SG_SCENE_FEATURES_HXX
 
+#include <OpenThreads/Mutex>
+
 #include <simgear/structure/SGReferenced.hxx>
 
 namespace osg { class Texture; }
@@ -94,6 +96,8 @@ private:
   bool _pointSpriteLights;
   bool _distanceAttenuationLights;
   int  _textureFilter;
+
+  static OpenThreads::Mutex _instanceMutex;
 };
 
 #endif
index 41bd3272b2b0d8ba3d4757d33ef71510cf9c8902..80877375e96fa391c57c449e54aa1d670d73ad4e 100644 (file)
@@ -5,8 +5,9 @@
 
 #include <cassert>
 #include <queue>
-#include "SGThread.hxx"
-#include "SGGuard.hxx"
+#include <OpenThreads/Mutex>
+#include <OpenThreads/ScopedLock>
+#include <OpenThreads/Condition>
 
 /**
  * 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.
  */
-template<class T, class SGLOCK=SGMutex>
+template<class T, class SGLOCK=OpenThreads::Mutex>
 class SGLockedQueue : public SGQueue<T>
 {
 public:
@@ -94,7 +95,7 @@ public:
      * @return bool True if queue is empty, otherwisr false.
      */
     virtual bool empty() {
-       SGGuard<SGLOCK> g(mutex);
+       OpenThreads::ScopedLock<SGLOCK> g(mutex);
        return this->fifo.empty();
     }
 
@@ -104,7 +105,7 @@ public:
      * @param T object to add.
      */
     virtual void push( const T& item ) {
-       SGGuard<SGLOCK> g(mutex);
+       OpenThreads::ScopedLock<SGLOCK> g(mutex);
        this->fifo.push( item );
     }
 
@@ -114,7 +115,7 @@ public:
      * @return T next available object.
      */
     virtual T front() {
-       SGGuard<SGLOCK> g(mutex);
+       OpenThreads::ScopedLock<SGLOCK> g(mutex);
        assert( ! this->fifo.empty() );
        T item = this->fifo.front();
        return item;
@@ -126,7 +127,7 @@ public:
      * @return T next available object.
      */
     virtual T pop() {
-       SGGuard<SGLOCK> g(mutex);
+       OpenThreads::ScopedLock<SGLOCK> g(mutex);
        //if (fifo.empty()) throw NoSuchElementException();
        assert( ! this->fifo.empty() );
 //     if (fifo.empty())
@@ -145,7 +146,7 @@ public:
      * @return size_t size of queue.
      */
     virtual size_t size() {
-       SGGuard<SGLOCK> g(mutex);
+       OpenThreads::ScopedLock<SGLOCK> g(mutex);
         return this->fifo.size();
     }
 
@@ -184,7 +185,7 @@ public:
      * 
      */
     virtual bool empty() {
-       SGGuard<SGMutex> g(mutex);
+       OpenThreads::ScopedLock<OpenThreads::Mutex> g(mutex);
        return this->fifo.empty();
     }
 
@@ -194,7 +195,7 @@ public:
      * @param T object to add.
      */
     virtual void push( const T& item ) {
-       SGGuard<SGMutex> g(mutex);
+       OpenThreads::ScopedLock<OpenThreads::Mutex> g(mutex);
        this->fifo.push( item );
        not_empty.signal();
     }
@@ -206,7 +207,7 @@ public:
      * @return T next available object.
      */
     virtual T front() {
-       SGGuard<SGMutex> g(mutex);
+       OpenThreads::ScopedLock<OpenThreads::Mutex> g(mutex);
 
        assert(this->fifo.empty() != true);
        //if (fifo.empty()) throw ??
@@ -222,10 +223,10 @@ public:
      * @return T next available object.
      */
     virtual T pop() {
-       SGGuard<SGMutex> g(mutex);
+       OpenThreads::ScopedLock<OpenThreads::Mutex> g(mutex);
 
        while (this->fifo.empty())
-           not_empty.wait(mutex);
+           not_empty.wait(&mutex);
 
        assert(this->fifo.empty() != true);
        //if (fifo.empty()) throw ??
@@ -241,7 +242,7 @@ public:
      * @return size_t size of queue.
      */
     virtual size_t size() {
-       SGGuard<SGMutex> g(mutex);
+       OpenThreads::ScopedLock<OpenThreads::Mutex> g(mutex);
         return this->fifo.size();
     }
 
@@ -250,12 +251,12 @@ private:
     /**
      * Mutex to serialise access.
      */
-    SGMutex mutex;
+    OpenThreads::Mutex mutex;
 
     /**
      * Condition to signal when queue not empty.
      */
-    SGPthreadCond not_empty;
+    OpenThreads::Condition not_empty;
 
 private:
     // Prevent copying.