1
0
Fork 0

From Benoit Laniel: replace SG threading constructs with OpenThreads

This commit is contained in:
timoore 2008-06-12 08:24:39 +00:00
parent 0317d992b9
commit a9319336ba
4 changed files with 14 additions and 9 deletions

View file

@ -356,7 +356,8 @@ FGMetarEnvironmentCtrl::FGMetarEnvironmentCtrl ()
{ {
#if defined(ENABLE_THREADS) #if defined(ENABLE_THREADS)
thread = new MetarThread(this); thread = new MetarThread(this);
thread->start( 1 ); thread->setProcessorAffinity(1);
thread->start();
#endif // ENABLE_THREADS #endif // ENABLE_THREADS
} }

View file

@ -32,7 +32,7 @@
#include <simgear/environment/metar.hxx> #include <simgear/environment/metar.hxx>
#if defined(ENABLE_THREADS) #if defined(ENABLE_THREADS)
# include <simgear/threads/SGThread.hxx> # include <OpenThreads/Thread>
# include <simgear/threads/SGQueue.hxx> # include <simgear/threads/SGQueue.hxx>
#endif #endif
@ -233,7 +233,7 @@ private:
* This class represents the thread of execution responsible for * This class represents the thread of execution responsible for
* fetching the metar data. * fetching the metar data.
*/ */
class MetarThread : public SGThread class MetarThread : public OpenThreads::Thread
{ {
public: public:
MetarThread( FGMetarEnvironmentCtrl* f ) : fetcher(f) {} MetarThread( FGMetarEnvironmentCtrl* f ) : fetcher(f) {}

View file

@ -71,7 +71,8 @@ void FGVoiceMgr::init()
} }
#if defined(ENABLE_THREADS) #if defined(ENABLE_THREADS)
_thread->start(1); _thread->setProcessorAffinity(1);
_thread->start();
#endif #endif
} }

View file

@ -37,7 +37,10 @@
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#if defined(ENABLE_THREADS) #if defined(ENABLE_THREADS)
# include <simgear/threads/SGThread.hxx> # include <OpenThreads/Thread>
# include <OpenThreads/Mutex>
# include <OpenThreads/ScopedLock>
# include <OpenThreads/Condition>
# include <simgear/threads/SGQueue.hxx> # include <simgear/threads/SGQueue.hxx>
#else #else
# include <queue> # include <queue>
@ -74,16 +77,16 @@ private:
#if defined(ENABLE_THREADS) #if defined(ENABLE_THREADS)
class FGVoiceMgr::FGVoiceThread : public SGThread { class FGVoiceMgr::FGVoiceThread : public OpenThreads::Thread {
public: public:
FGVoiceThread(FGVoiceMgr *mgr) : _mgr(mgr) {} FGVoiceThread(FGVoiceMgr *mgr) : _mgr(mgr) {}
void run(); void run();
void wake_up() { _jobs.signal(); } void wake_up() { _jobs.signal(); }
private: private:
void wait_for_jobs() { SGGuard<SGMutex> g(_mutex); _jobs.wait(_mutex); } void wait_for_jobs() { OpenThreads::ScopedLock<OpenThreads::Mutex> g(_mutex); _jobs.wait(&_mutex); }
SGPthreadCond _jobs; OpenThreads::Condition _jobs;
SGMutex _mutex; OpenThreads::Mutex _mutex;
FGVoiceMgr *_mgr; FGVoiceMgr *_mgr;
}; };
#endif #endif