From a9319336badc474eb794af891b3bd6c63a81a62d Mon Sep 17 00:00:00 2001 From: timoore Date: Thu, 12 Jun 2008 08:24:39 +0000 Subject: [PATCH] From Benoit Laniel: replace SG threading constructs with OpenThreads --- src/Environment/environment_ctrl.cxx | 3 ++- src/Environment/environment_ctrl.hxx | 4 ++-- src/Sound/voice.cxx | 3 ++- src/Sound/voice.hxx | 13 ++++++++----- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Environment/environment_ctrl.cxx b/src/Environment/environment_ctrl.cxx index 1446b982f..66bb8e484 100644 --- a/src/Environment/environment_ctrl.cxx +++ b/src/Environment/environment_ctrl.cxx @@ -356,7 +356,8 @@ FGMetarEnvironmentCtrl::FGMetarEnvironmentCtrl () { #if defined(ENABLE_THREADS) thread = new MetarThread(this); - thread->start( 1 ); + thread->setProcessorAffinity(1); + thread->start(); #endif // ENABLE_THREADS } diff --git a/src/Environment/environment_ctrl.hxx b/src/Environment/environment_ctrl.hxx index 69b2bdf22..ace7af410 100644 --- a/src/Environment/environment_ctrl.hxx +++ b/src/Environment/environment_ctrl.hxx @@ -32,7 +32,7 @@ #include #if defined(ENABLE_THREADS) -# include +# include # include #endif @@ -233,7 +233,7 @@ private: * This class represents the thread of execution responsible for * fetching the metar data. */ - class MetarThread : public SGThread + class MetarThread : public OpenThreads::Thread { public: MetarThread( FGMetarEnvironmentCtrl* f ) : fetcher(f) {} diff --git a/src/Sound/voice.cxx b/src/Sound/voice.cxx index d3af41471..cdd90d330 100644 --- a/src/Sound/voice.cxx +++ b/src/Sound/voice.cxx @@ -71,7 +71,8 @@ void FGVoiceMgr::init() } #if defined(ENABLE_THREADS) - _thread->start(1); + _thread->setProcessorAffinity(1); + _thread->start(); #endif } diff --git a/src/Sound/voice.hxx b/src/Sound/voice.hxx index b059df179..117ee3aad 100644 --- a/src/Sound/voice.hxx +++ b/src/Sound/voice.hxx @@ -37,7 +37,10 @@ #include
#if defined(ENABLE_THREADS) -# include +# include +# include +# include +# include # include #else # include @@ -74,16 +77,16 @@ private: #if defined(ENABLE_THREADS) -class FGVoiceMgr::FGVoiceThread : public SGThread { +class FGVoiceMgr::FGVoiceThread : public OpenThreads::Thread { public: FGVoiceThread(FGVoiceMgr *mgr) : _mgr(mgr) {} void run(); void wake_up() { _jobs.signal(); } private: - void wait_for_jobs() { SGGuard g(_mutex); _jobs.wait(_mutex); } - SGPthreadCond _jobs; - SGMutex _mutex; + void wait_for_jobs() { OpenThreads::ScopedLock g(_mutex); _jobs.wait(&_mutex); } + OpenThreads::Condition _jobs; + OpenThreads::Mutex _mutex; FGVoiceMgr *_mgr; }; #endif -- 2.39.5