- 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
This commit is contained in:
parent
c9813d1b5d
commit
1fe9cce53b
2 changed files with 1 additions and 31 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue