code to protect against potential race condition when timer queue is destroyed

This commit is contained in:
Jeff Hill
2000-02-09 22:18:05 +00:00
parent ff75a04031
commit 3fe6392a93
2 changed files with 13 additions and 5 deletions

View File

@@ -223,7 +223,7 @@ void osiTimer::arm (osiTimerQueue &queueIn, double initialDelay)
queueIn.mutex.unlock ();
queueIn.event.signal ();
queueIn.rescheduleEvent.signal ();
}
//
@@ -319,7 +319,7 @@ void osiTimer::unlock () const
//
osiTimerQueue::osiTimerQueue (unsigned managerThreadPriority) :
osiThread ("osiTimerQueue", threadGetStackSize (threadStackMedium), managerThreadPriority),
pExpireTmr (0), inProcess (false), terminateFlag (false)
pExpireTmr (0), inProcess (false), terminateFlag (false), exitFlag (false)
{
}
@@ -348,7 +348,10 @@ osiTimerQueue::~osiTimerQueue()
pTmr->destroy ();
}
this->terminateFlag = true;
this->event.signal ();
this->rescheduleEvent.signal ();
while (!this->exitFlag) {
this->exitEvent.wait ();
}
}
//
@@ -356,10 +359,13 @@ osiTimerQueue::~osiTimerQueue()
//
void osiTimerQueue::entryPoint ()
{
this->exitFlag = false;
while (!this->terminateFlag) {
this->process ();
this->event.wait ( this->delayToFirstExpire () );
this->rescheduleEvent.wait ( this->delayToFirstExpire () );
}
this->exitFlag = true;
this->exitEvent.signal (); // no access to this ptr after this statement
}
//