auto mutex release now requires an auto mutex

This commit is contained in:
Jeff Hill
2002-02-27 23:32:44 +00:00
parent 7180f5e66e
commit a251b89e13
5 changed files with 17 additions and 16 deletions

View File

@@ -147,7 +147,7 @@ ipAddrToAsciiAsynchronous::~ipAddrToAsciiAsynchronous ()
! this->pEngine->thread.isCurrentThread() ) {
this->pEngine->cancelPending = true;
{
epicsAutoMutexRelease unlocker ( ipAddrToAsciiEngine::mutex );
epicsAutoMutexRelease unlocker ( locker );
this->pEngine->destructorBlockEvent.wait ();
}
if ( ! this->pEngine ) {

View File

@@ -25,9 +25,9 @@ public:
class noMemory {}; // exception
class invalidSemaphore {}; // exception
private:
epicsMutexId id;
epicsMutex ( const epicsMutex & );
epicsMutex & operator = ( const epicsMutex & );
epicsMutexId id;
};
// Automatically applies and releases the mutex.
@@ -37,21 +37,22 @@ public:
epicsAutoMutex ( epicsMutex & );
~epicsAutoMutex ();
private:
epicsMutex & rMutex;
epicsAutoMutex ( const epicsAutoMutex & );
epicsAutoMutex & operator = ( const epicsAutoMutex & );
epicsMutex & rMutex;
friend class epicsAutoMutexRelease;
};
// Automatically releases and reapplies the mutex.
// This is for use in situations where C++ exceptions are possible.
class epicsAutoMutexRelease {
public:
epicsAutoMutexRelease ( epicsMutex & );
epicsAutoMutexRelease ( epicsAutoMutex & );
~epicsAutoMutexRelease ();
private:
epicsAutoMutexRelease ( const epicsAutoMutex & );
epicsAutoMutex & autoMutex;
epicsAutoMutexRelease ( const epicsAutoMutexRelease & );
epicsAutoMutexRelease & operator = ( const epicsAutoMutexRelease & );
epicsMutex & rMutex;
};
@@ -167,15 +168,15 @@ inline epicsAutoMutex :: ~epicsAutoMutex ()
this->rMutex.unlock ();
}
inline epicsAutoMutexRelease :: epicsAutoMutexRelease ( epicsMutex & mutexIn ) :
rMutex ( mutexIn )
inline epicsAutoMutexRelease :: epicsAutoMutexRelease ( epicsAutoMutex & autoMutexIn ) :
autoMutex ( autoMutexIn )
{
this->rMutex.unlock ();
this->autoMutex.rMutex.unlock ();
}
inline epicsAutoMutexRelease :: ~epicsAutoMutexRelease ()
{
this->rMutex.lock ();
this->autoMutex.rMutex.lock ();
}
#endif /*__cplusplus*/

View File

@@ -68,7 +68,7 @@ void timer::start ( epicsTimerNotify & notify, double delaySeconds )
void timer::start ( epicsTimerNotify & notify, const epicsTime & expire )
{
epicsAutoMutex locker ( this->queue.mutex );
this->privateCancel ();
this->privateCancel ( locker );
this->privateStart ( notify, expire );
}
@@ -127,10 +127,10 @@ void timer::privateStart ( epicsTimerNotify & notify, const epicsTime & expire )
void timer::cancel ()
{
epicsAutoMutex locker ( this->queue.mutex );
this->privateCancel ();
this->privateCancel ( locker );
}
void timer::privateCancel ()
void timer::privateCancel ( epicsAutoMutex & locker )
{
while ( true ) {
if ( this->curState == statePending ) {
@@ -147,7 +147,7 @@ void timer::privateCancel ()
// make certain timer expire() does not run after cancel () returns,
// but dont require that lock is applied while calling expire()
{
epicsAutoMutexRelease autoRelease ( this->queue.mutex );
epicsAutoMutexRelease autoRelease ( locker );
while ( this->queue.cancelPending ) {
this->queue.cancelBlockingEvent.wait ();
}

View File

@@ -60,7 +60,7 @@ private:
epicsTimerNotify *pNotify; // callback
timerQueue &queue;
void privateStart ( epicsTimerNotify & notify, const epicsTime & );
void privateCancel ();
void privateCancel ( epicsAutoMutex & );
timer & operator = ( const timer & );
friend class timerQueue;
};

View File

@@ -41,7 +41,7 @@ epicsTimerQueueActive &epicsTimerQueueActive::allocate ( bool okToShare, unsigne
}
timerQueueActive::timerQueueActive ( bool okToShareIn, unsigned priority ) :
queue ( *this ), thread ( *this, "epicsTimerQueueActive",
queue ( *this ), thread ( *this, "timerQueue",
epicsThreadGetStackSize ( epicsThreadStackMedium ), priority ),
okToShare ( okToShareIn ), exitFlag ( false ), terminateFlag ( false )
{