]> git.mxchange.org Git - simgear.git/commitdiff
Since we're now sure 1.9.1 will not be released from trunk, here's Yon
authorjmt <jmt>
Thu, 15 Jan 2009 14:31:51 +0000 (14:31 +0000)
committerTim Moore <timoore@redhat.com>
Thu, 15 Jan 2009 21:49:00 +0000 (22:49 +0100)
Uriarte's patch to convert SGReferenced over to OpenThread's atomic int.

simgear/structure/SGReferenced.hxx
simgear/structure/commands.cxx
simgear/structure/commands.hxx

index 6a3038f3576494619e6590144ce3d638d547be31..6bce1eb82bd83da9e4fce1d88e37c414340baf91 100644 (file)
 
 #ifndef SGReferenced_HXX
 #define SGReferenced_HXX
+#define USE_OPENTHREADS_ATOMIC
 
+#ifndef USE_OPENTHREADS_ATOMIC
 #include "SGAtomic.hxx"
+#else
+#include <OpenThreads/Atomic>
+#endif
 
 /// Base class for all reference counted SimGear objects
 /// 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; }
 
 private:
+#ifndef USE_OPENTHREADS_ATOMIC
   mutable SGAtomic _refcount;
+#else
+  mutable OpenThreads::Atomic _refcount;
+#endif
 };
 
 #endif
index 49a9c63cde0d605c94d73f537a7cc5b95f515126..16706d96ecde648e8095fdb78cd2674ccbecd086 100644 (file)
@@ -6,8 +6,9 @@
 
 #include <memory>
 #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"
 
@@ -28,6 +29,8 @@ SGCommandMgr::~SGCommandMgr ()
   // no-op
 }
 
+OpenThreads::Mutex SGCommandMgr::_instanceMutex;
+
 SGCommandMgr*
 SGCommandMgr::instance()
 {
@@ -35,8 +38,7 @@ SGCommandMgr::instance()
   if (mgr.get())
     return mgr.get();
 
-  static SGMutex lock;
-  SGGuard<SGMutex> guard(lock);
+  OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_instanceMutex);
   if (mgr.get())
     return mgr.get();
 
index 21f44963500dff42f180f2391dffe4de0aee7030..0825ffd9fc58c3c97b966d3d498dd11892acd1a6 100644 (file)
@@ -17,6 +17,8 @@
 #include <map>
 #include <vector>
 
+#include <OpenThreads/Mutex>
+
 #include <simgear/props/props.hxx>
 
 using std::string;
@@ -109,6 +111,8 @@ private:
   typedef map<string,command_t> command_map;
   command_map _commands;
 
+  static OpenThreads::Mutex _instanceMutex;
+
 };
 
 #endif // __COMMANDS_HXX