Uriarte's patch to convert SGReferenced over to OpenThread's atomic int.
#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
{ if (ref) return 1u < ref->_refcount; else return false; }
private:
+#ifndef USE_OPENTHREADS_ATOMIC
mutable SGAtomic _refcount;
+#else
+ mutable OpenThreads::Atomic _refcount;
+#endif
};
#endif
#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"
// no-op
}
+OpenThreads::Mutex SGCommandMgr::_instanceMutex;
+
SGCommandMgr*
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();
#include <map>
#include <vector>
+#include <OpenThreads/Mutex>
+
#include <simgear/props/props.hxx>
using std::string;
typedef map<string,command_t> command_map;
command_map _commands;
+ static OpenThreads::Mutex _instanceMutex;
+
};
#endif // __COMMANDS_HXX