]> git.mxchange.org Git - flightgear.git/commitdiff
- remove unused pthread mutex and condition
authormfranz <mfranz>
Tue, 21 Feb 2006 13:19:33 +0000 (13:19 +0000)
committermfranz <mfranz>
Tue, 21 Feb 2006 13:19:33 +0000 (13:19 +0000)
- 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
src/Environment/environment_ctrl.hxx

index ebfc97e6dfec678f379ce149215059f7bb436dda..f4bf66e88a92f056723be6e180ab46ee920714a1 100644 (file)
@@ -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
 
index 389419aa10d4554c7893828c669c215eeb2295b8..f2266305c1c52422d65bc15563258f1374f0cbc4 100644 (file)
@@ -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