From 1fe9cce53b2925b5a3e4229b4f31d848d523d7a6 Mon Sep 17 00:00:00 2001 From: mfranz Date: Tue, 21 Feb 2006 13:19:33 +0000 Subject: [PATCH] - remove unused pthread mutex and condition - remove cleanup handler that unlocks unused mutex - make the result_queue a locking queue (blocking is only done in the pop() anyway, and this isn't used in the thread at all) - don't disallow thread cancelling in the request_queue's pop(), which is the only cancellation point in this thread --- src/Environment/environment_ctrl.cxx | 20 -------------------- src/Environment/environment_ctrl.hxx | 12 +----------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/src/Environment/environment_ctrl.cxx b/src/Environment/environment_ctrl.cxx index ebfc97e6d..f4bf66e88 100644 --- a/src/Environment/environment_ctrl.cxx +++ b/src/Environment/environment_ctrl.cxx @@ -707,36 +707,16 @@ FGMetarEnvironmentCtrl::update_metar_properties( const FGMetar *m ) #if defined(ENABLE_THREADS) -/** - * Ensure mutex is unlocked. - */ -void -metar_cleanup_handler( void* arg ) -{ - FGMetarEnvironmentCtrl* fetcher = (FGMetarEnvironmentCtrl*) arg; - fetcher->mutex.unlock(); -} - -/** - * - */ void FGMetarEnvironmentCtrl::MetarThread::run() { - pthread_cleanup_push( metar_cleanup_handler, fetcher ); while ( true ) { - set_cancel( SGThread::CANCEL_DISABLE ); - string icao = fetcher->request_queue.pop(); SG_LOG( SG_GENERAL, SG_INFO, "Thread: fetch metar data = " << icao ); FGMetarResult result = fetcher->fetch_data( icao ); - - set_cancel( SGThread::CANCEL_DEFERRED ); - fetcher->result_queue.push( result ); } - pthread_cleanup_pop(1); } #endif // ENABLE_THREADS diff --git a/src/Environment/environment_ctrl.hxx b/src/Environment/environment_ctrl.hxx index 389419aa1..f2266305c 100644 --- a/src/Environment/environment_ctrl.hxx +++ b/src/Environment/environment_ctrl.hxx @@ -194,7 +194,7 @@ private: /** * FIFO queue which holds a pointer to the fetched metar data. */ - SGBlockingQueue < FGMetarResult > result_queue; + SGLockedQueue < FGMetarResult > result_queue; #else /** * FIFO queue which holds a pointer to the fetched metar data. @@ -240,16 +240,6 @@ private: */ MetarThread* thread; - /** - * Lock and synchronize access to metar queue. - */ - SGMutex mutex; - SGPthreadCond metar_cond; - - /** - * Thread cleanup handler. - */ - friend void metar_cleanup_handler( void* ); #endif // ENABLE_THREADS -- 2.39.5