From 8ef0216cf500d2f748fb04b7dbfc0a91c4ec9d7f Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Mon, 26 Mar 2001 18:34:59 +0000 Subject: [PATCH] minor optimization in timer queue process --- src/libCom/timer/timerQueue.cpp | 71 +++++++++++++++++---------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/libCom/timer/timerQueue.cpp b/src/libCom/timer/timerQueue.cpp index b2e82dbae..7ab8c28fb 100644 --- a/src/libCom/timer/timerQueue.cpp +++ b/src/libCom/timer/timerQueue.cpp @@ -73,27 +73,27 @@ void timerQueue::process () return; } - this->pExpireTmr = this->timerList.get (); - if ( ! this->pExpireTmr ) { - return; - } - if ( cur > this->pExpireTmr->exp ) { - - // - // Tag current epired tmr so that we can detect if call back - // is in progress when canceling the timer. - // -# ifdef DEBUG - this->pExpireTmr->show ( 0u ); -# endif - this->pExpireTmr->curState = timer::stateLimbo; - this->processThread = epicsThreadGetIdSelf (); + this->pExpireTmr = this->timerList.first (); + if ( this->pExpireTmr ) { + if ( cur >= this->pExpireTmr->exp ) { + this->timerList.remove ( *this->pExpireTmr ); + // + // Tag current epired tmr so that we can detect if call back + // is in progress when canceling the timer. + // + this->pExpireTmr->curState = timer::stateLimbo; + this->processThread = epicsThreadGetIdSelf (); +# ifdef DEBUG + this->pExpireTmr->show ( 0u ); +# endif + } + else { + this->pExpireTmr = 0; + debugPrintf ( ( "no activity process %f to next\n", this->pExpireTmr->exp - cur ) ); + return; + } } else { - // no activity - debugPrintf ( ( "no activity process\n" ) ); - this->timerList.push ( *this->pExpireTmr ); - this->pExpireTmr = 0; return; } } @@ -117,30 +117,31 @@ void timerQueue::process () // while the call back was running // if ( this->cancelPending ) { - // cancel () waits for this + // cancel() waits for this this->cancelPending = false; this->cancelBlockingEvent.signal (); } // restart as nec - else if ( expStat.restart () ) { - this->pExpireTmr->privateStart ( cur + expStat.expirationDelay () ); + else if ( expStat.restart() ) { + this->pExpireTmr->privateStart ( cur + expStat.expirationDelay() ); } - this->pExpireTmr = this->timerList.get (); - if ( ! this->pExpireTmr ) { - this->processThread = 0; - return; - } - if ( cur > this->pExpireTmr->exp ) { -# ifdef DEBUG - this->pExpireTmr->show ( 0u ); -# endif - this->pExpireTmr->curState = timer::stateLimbo; + this->pExpireTmr = this->timerList.first (); + if ( this->pExpireTmr ) { + if ( cur >= this->pExpireTmr->exp ) { + this->timerList.remove ( *this->pExpireTmr ); + this->pExpireTmr->curState = timer::stateLimbo; +# ifdef DEBUG + this->pExpireTmr->show ( 0u ); +# endif + } + else { + this->pExpireTmr = 0; + this->processThread = 0; + return; + } } else { - // no activity - this->timerList.push ( *this->pExpireTmr ); - this->pExpireTmr = 0; this->processThread = 0; return; }