diff --git a/src/ca/repeaterSubscribeTimer.cpp b/src/ca/repeaterSubscribeTimer.cpp index c1775c6f9..193ba4594 100644 --- a/src/ca/repeaterSubscribeTimer.cpp +++ b/src/ca/repeaterSubscribeTimer.cpp @@ -30,7 +30,7 @@ repeaterSubscribeTimer::repeaterSubscribeTimer ( udpiiu &iiuIn, epicsTimerQueue repeaterSubscribeTimer::~repeaterSubscribeTimer () { - this->timer.getQueue().destroyTimer ( this->timer ); + this->timer.destroy (); } epicsTimerNotify::expireStatus repeaterSubscribeTimer::expire ( const epicsTime & currentTime ) diff --git a/src/ca/searchTimer.cpp b/src/ca/searchTimer.cpp index 11c7021b2..ce5a421a5 100644 --- a/src/ca/searchTimer.cpp +++ b/src/ca/searchTimer.cpp @@ -57,7 +57,7 @@ searchTimer::searchTimer ( udpiiu &iiuIn, epicsTimerQueue &queueIn, epicsMutex & searchTimer::~searchTimer () { - this->timer.getQueue().destroyTimer ( this->timer ); + this->timer.destroy (); } // diff --git a/src/ca/tcpRecvWatchdog.cpp b/src/ca/tcpRecvWatchdog.cpp index 8618281f7..192dd9fa9 100644 --- a/src/ca/tcpRecvWatchdog.cpp +++ b/src/ca/tcpRecvWatchdog.cpp @@ -28,7 +28,7 @@ tcpRecvWatchdog::tcpRecvWatchdog tcpRecvWatchdog::~tcpRecvWatchdog () { - this->timer.getQueue().destroyTimer ( this->timer ); + this->timer.destroy (); } epicsTimerNotify::expireStatus tcpRecvWatchdog::expire ( const epicsTime & /* currentTime */ ) diff --git a/src/ca/tcpSendWatchdog.cpp b/src/ca/tcpSendWatchdog.cpp index bc07355cb..4ff1c69d9 100644 --- a/src/ca/tcpSendWatchdog.cpp +++ b/src/ca/tcpSendWatchdog.cpp @@ -24,7 +24,7 @@ tcpSendWatchdog::tcpSendWatchdog tcpSendWatchdog::~tcpSendWatchdog () { - this->timer.getQueue().destroyTimer ( this->timer ); + this->timer.destroy (); } epicsTimerNotify::expireStatus tcpSendWatchdog::expire ( const epicsTime & currentTime ) diff --git a/src/cas/example/simple/exAsyncPV.cc b/src/cas/example/simple/exAsyncPV.cc index 4c905082d..5a24249e9 100644 --- a/src/cas/example/simple/exAsyncPV.cc +++ b/src/cas/example/simple/exAsyncPV.cc @@ -68,7 +68,7 @@ exAsyncWriteIO::~exAsyncWriteIO() { this->pv.removeIO(); if ( this->pv.getCAS() ) { - this->pv.getCAS()->destroyTimer ( this->timer ); + this->timer.destroy (); } } @@ -102,7 +102,7 @@ exAsyncReadIO::~exAsyncReadIO() { this->pv.removeIO (); if ( this->pv.getCAS() ) { - this->pv.getCAS()->destroyTimer ( this->timer ); + this->timer.destroy (); } } diff --git a/src/cas/example/simple/exPV.cc b/src/cas/example/simple/exPV.cc index 44a449937..968d19c86 100644 --- a/src/cas/example/simple/exPV.cc +++ b/src/cas/example/simple/exPV.cc @@ -49,7 +49,7 @@ exPV::exPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) : exPV::~exPV() { if ( this->getCAS() ) { - this->getCAS()->destroyTimer ( this->timer ); + this->timer.destroy (); } this->info.unlinkPV(); } diff --git a/src/cas/example/simple/exServer.cc b/src/cas/example/simple/exServer.cc index ab94ad200..2a5e59639 100644 --- a/src/cas/example/simple/exServer.cc +++ b/src/cas/example/simple/exServer.cc @@ -329,7 +329,7 @@ exAsyncExistIO::exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn, exAsyncExistIO::~exAsyncExistIO() { this->cas.removeIO (); - this->cas.destroyTimer ( this->timer ); + this->timer.destroy (); } // @@ -364,7 +364,7 @@ exAsyncCreateIO::exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn, exAsyncCreateIO::~exAsyncCreateIO() { this->cas.removeIO (); - this->cas.destroyTimer ( this->timer ); + this->timer.destroy (); } // diff --git a/src/cas/generic/caServer.cc b/src/cas/generic/caServer.cc index 2fdf50dfd..b50c6fee4 100644 --- a/src/cas/generic/caServer.cc +++ b/src/cas/generic/caServer.cc @@ -213,11 +213,6 @@ class epicsTimer & caServer::createTimer () return fileDescriptorManager.createTimer (); } -void caServer::destroyTimer ( class epicsTimer & tmr ) -{ - fileDescriptorManager.destroyTimer ( tmr ); -} - // // caServer::readEventsProcessedCounter // diff --git a/src/cas/generic/casdef.h b/src/cas/generic/casdef.h index e059d9f24..39c83f2eb 100644 --- a/src/cas/generic/casdef.h +++ b/src/cas/generic/casdef.h @@ -374,7 +374,6 @@ public: #endif epicsShareFunc class epicsTimer & createTimer (); - epicsShareFunc void destroyTimer ( class epicsTimer & ); //caStatus enableClients (); //caStatus disableClients (); diff --git a/src/cas/generic/st/caServerOS.cc b/src/cas/generic/st/caServerOS.cc index f05229315..5414b24f4 100644 --- a/src/cas/generic/st/caServerOS.cc +++ b/src/cas/generic/st/caServerOS.cc @@ -34,7 +34,7 @@ casBeaconTimer::casBeaconTimer ( double delay, caServerOS &osIn ) : casBeaconTimer::~casBeaconTimer () { - fileDescriptorManager.destroyTimer ( this->timer ); + this->timer.destroy (); } // diff --git a/src/cas/generic/st/casDGIntfOS.cc b/src/cas/generic/st/casDGIntfOS.cc index de70af25c..41b0ed084 100644 --- a/src/cas/generic/st/casDGIntfOS.cc +++ b/src/cas/generic/st/casDGIntfOS.cc @@ -100,7 +100,7 @@ casDGEvWakeup::casDGEvWakeup () : // casDGEvWakeup::~casDGEvWakeup() { - fileDescriptorManager.destroyTimer ( this->timer ); + this->timer.destroy (); } void casDGEvWakeup::start ( casDGIntfOS &os ) @@ -148,7 +148,7 @@ casDGIOWakeup::casDGIOWakeup () : // casDGIOWakeup::~casDGIOWakeup() { - fileDescriptorManager.destroyTimer ( this->timer ); + this->timer.destroy (); } // diff --git a/src/cas/generic/st/casStreamOS.cc b/src/cas/generic/st/casStreamOS.cc index beee7eb4b..25638f192 100644 --- a/src/cas/generic/st/casStreamOS.cc +++ b/src/cas/generic/st/casStreamOS.cc @@ -117,7 +117,7 @@ casStreamEvWakeup::casStreamEvWakeup () : // casStreamEvWakeup::~casStreamEvWakeup() { - fileDescriptorManager.destroyTimer ( this->timer ); + this->timer.destroy (); } // @@ -185,7 +185,7 @@ casStreamIOWakeup::casStreamIOWakeup () : // casStreamIOWakeup::~casStreamIOWakeup() { - fileDescriptorManager.destroyTimer ( this->timer ); + this->timer.deatroy (); } // diff --git a/src/libCom/fdmgr/fdManager.h b/src/libCom/fdmgr/fdManager.h index 5260aa387..72c93a0e0 100644 --- a/src/libCom/fdmgr/fdManager.h +++ b/src/libCom/fdmgr/fdManager.h @@ -103,7 +103,6 @@ public: epicsShareFunc class fdReg *lookUpFD (const SOCKET fd, const fdRegType type); epicsTimer & createTimer (); - void destroyTimer ( epicsTimer & ); private: tsDLList regList; @@ -212,10 +211,5 @@ inline epicsTimer & fdManager::createTimer () return this->pTimerQueue->createTimer (); } -inline void fdManager::destroyTimer ( epicsTimer & tmr ) -{ - this->pTimerQueue->destroyTimer ( tmr ); -} - #endif // fdManagerH_included diff --git a/src/libCom/fdmgr/fdmgr.cpp b/src/libCom/fdmgr/fdmgr.cpp index cdd8d7f26..c34c16e93 100644 --- a/src/libCom/fdmgr/fdmgr.cpp +++ b/src/libCom/fdmgr/fdmgr.cpp @@ -135,7 +135,7 @@ timerForOldFdmgr::timerForOldFdmgr ( oldFdmgr &fdmgrIn, timerForOldFdmgr::~timerForOldFdmgr () { this->fdmgr.resTbl.remove ( this->getId() ); - this->fdmgr.destroyTimer ( this->timer ); + this->timer.destroy (); } epicsTimerNotify::expireStatus timerForOldFdmgr::expire ( const epicsTime & ) diff --git a/src/libCom/test/epicsTimerTest.cpp b/src/libCom/test/epicsTimerTest.cpp index c7f2e71ef..5482781d5 100644 --- a/src/libCom/test/epicsTimerTest.cpp +++ b/src/libCom/test/epicsTimerTest.cpp @@ -68,7 +68,7 @@ delayVerify::delayVerify ( double expectedDelayIn, epicsTimerQueue &queueIn ) : delayVerify::~delayVerify () { - this->timer.getQueue().destroyTimer ( this->timer ); + this->timer.destroy (); } inline void delayVerify::setBegin ( const epicsTime &beginIn ) @@ -177,7 +177,7 @@ cancelVerify::cancelVerify ( epicsTimerQueue &queueIn ) : cancelVerify::~cancelVerify () { - this->timer.getQueue().destroyTimer ( this->timer ); + this->timer.destroy (); } inline void cancelVerify::start ( const epicsTime &expireTime ) @@ -271,7 +271,7 @@ periodicVerify::periodicVerify ( epicsTimerQueue & queueIn ) : periodicVerify::~periodicVerify () { - this->timer.getQueue().destroyTimer ( this->timer ); + this->timer.destroy (); } inline void periodicVerify::start ( const epicsTime &expireTime ) diff --git a/src/libCom/timer/epicsTimer.cpp b/src/libCom/timer/epicsTimer.cpp index a9625654f..7aa053966 100644 --- a/src/libCom/timer/epicsTimer.cpp +++ b/src/libCom/timer/epicsTimer.cpp @@ -50,6 +50,8 @@ private: epicsTimer::~epicsTimer () {} +epicsTimerQueueNotify::~epicsTimerQueueNotify () {} + void epicsTimerNotify::show ( unsigned /* level */ ) const {} epicsTimerForC::epicsTimerForC ( timerQueue &queue, epicsTimerCallback pCBIn, void *pPrivateIn ) : diff --git a/src/libCom/timer/epicsTimer.h b/src/libCom/timer/epicsTimer.h index 91188451f..1eb668c40 100644 --- a/src/libCom/timer/epicsTimer.h +++ b/src/libCom/timer/epicsTimer.h @@ -46,7 +46,7 @@ public: class epicsTimer { public: - virtual ~epicsTimer () = 0; + virtual void destroy () = 0; // requires existence of timer queue virtual void start ( epicsTimerNotify &, const epicsTime & ) = 0; virtual void start ( epicsTimerNotify &, double delaySeconds ) = 0; virtual void cancel () = 0; @@ -58,23 +58,25 @@ public: virtual expireInfo getExpireInfo () const = 0; double getExpireDelay (); virtual void show ( unsigned int level ) const = 0; - virtual class epicsTimerQueue & getQueue () const = 0; +protected: + virtual ~epicsTimer () = 0; // use destroy }; class epicsTimerQueue { public: - virtual ~epicsTimerQueue () = 0; virtual epicsTimer & createTimer () = 0; - virtual void destroyTimer ( epicsTimer & ) = 0; virtual void show ( unsigned int level ) const = 0; +protected: + virtual ~epicsTimerQueue () = 0; }; class epicsTimerQueueActive : public epicsTimerQueue { public: - virtual ~epicsTimerQueueActive () = 0; static epicsShareFunc epicsTimerQueueActive & allocate ( bool okToShare, int threadPriority = epicsThreadPriorityMin + 10 ); virtual void release () = 0; +protected: + virtual ~epicsTimerQueueActive () = 0; }; class epicsTimerQueueNotify { @@ -82,6 +84,8 @@ public: // called when a new timer is inserted into the queue and the // delay to the next expire has changed virtual void reschedule () = 0; +protected: + virtual ~epicsTimerQueueNotify () = 0; }; class epicsTimerQueuePassive : public epicsTimerQueue { diff --git a/src/libCom/timer/timer.cpp b/src/libCom/timer/timer.cpp index 1e4d2ed3c..7e9d591f9 100644 --- a/src/libCom/timer/timer.cpp +++ b/src/libCom/timer/timer.cpp @@ -42,6 +42,13 @@ timer::~timer () this->cancel (); } +void timer::destroy () +{ + epicsAutoMutex autoLock ( this->queue.mutex ); + this->~timer (); + this->queue.timerFreeList.release ( this, sizeof( *this ) ); +} + void timer::start ( epicsTimerNotify & notify, double delaySeconds ) { this->start ( notify, epicsTime::getCurrent () + delaySeconds ); @@ -177,11 +184,6 @@ void timer::show ( unsigned int level ) const } } -epicsTimerQueue & timer::getQueue () const -{ - return this->queue; -} - timerQueue & timer::getPrivTimerQueue() { return this->queue; diff --git a/src/libCom/timer/timerPrivate.h b/src/libCom/timer/timerPrivate.h index 26b8ac741..779c2364d 100644 --- a/src/libCom/timer/timerPrivate.h +++ b/src/libCom/timer/timerPrivate.h @@ -43,12 +43,12 @@ class timer : public epicsTimer, public tsDLNode < timer > { public: + void destroy (); void start ( class epicsTimerNotify &, const epicsTime & ); void start ( class epicsTimerNotify &, double delaySeconds ); void cancel (); expireInfo getExpireInfo () const; void show ( unsigned int level ) const; - epicsTimerQueue & getQueue () const; class timerQueue & getPrivTimerQueue (); protected: timer ( class timerQueue & ); @@ -83,7 +83,6 @@ public: virtual ~timerQueue (); double process ( const epicsTime & currentTime ); epicsTimer & createTimer (); - void destroyTimer ( epicsTimer & ); void show ( unsigned int level ) const; epicsTimerForC & createTimerForC ( epicsTimerCallback, void *pPrivateIn ); void destroyTimerForC ( epicsTimerForC & ); @@ -117,7 +116,6 @@ public: timerQueueActive ( bool okToShare, unsigned priority ); ~timerQueueActive () = 0; epicsTimer & createTimer (); - void destroyTimer ( epicsTimer & ); void show ( unsigned int level ) const; bool sharingOK () const; int threadPriority () const; @@ -167,7 +165,6 @@ class timerQueuePassive : public epicsTimerQueuePassive { public: timerQueuePassive ( epicsTimerQueueNotify & ); epicsTimer & createTimer (); - void destroyTimer ( epicsTimer & ); void show ( unsigned int level ) const; double process ( const epicsTime & currentTime ); epicsTimerForC & createTimerForC ( epicsTimerCallback, void *pPrivateIn ); diff --git a/src/libCom/timer/timerQueue.cpp b/src/libCom/timer/timerQueue.cpp index 1fa10a5a2..85baae980 100644 --- a/src/libCom/timer/timerQueue.cpp +++ b/src/libCom/timer/timerQueue.cpp @@ -163,13 +163,6 @@ epicsTimer & timerQueue::createTimer () return * new ( pBuf ) timer ( *this ); } -void timerQueue::destroyTimer ( epicsTimer & tmr ) -{ - epicsAutoMutex autoLock ( this->mutex ); - tmr.~epicsTimer (); - this->timerFreeList.release ( &tmr, sizeof( tmr ) ); -} - void timerQueue::show ( unsigned level ) const { epicsAutoMutex locker ( this->mutex ); diff --git a/src/libCom/timer/timerQueueActive.cpp b/src/libCom/timer/timerQueueActive.cpp index 4308caaba..d5d47cc11 100644 --- a/src/libCom/timer/timerQueueActive.cpp +++ b/src/libCom/timer/timerQueueActive.cpp @@ -76,12 +76,6 @@ epicsTimer & timerQueueActive::createTimer () return this->queue.createTimer (); } -void timerQueueActive::destroyTimer ( epicsTimer & et ) -{ - timer & tmr = dynamic_cast < timer & > ( et ); - this->queue.destroyTimer ( tmr ); -} - epicsTimerForC & timerQueueActive::createTimerForC ( epicsTimerCallback pCB, void *pPrivateIn ) { return this->queue.createTimerForC ( pCB, pPrivateIn ); diff --git a/src/libCom/timer/timerQueuePassive.cpp b/src/libCom/timer/timerQueuePassive.cpp index 2b8ca8a7a..0101a366b 100644 --- a/src/libCom/timer/timerQueuePassive.cpp +++ b/src/libCom/timer/timerQueuePassive.cpp @@ -60,12 +60,6 @@ epicsTimer & timerQueuePassive::createTimer () return this->queue.createTimer (); } -void timerQueuePassive::destroyTimer ( epicsTimer & et ) -{ - timer & tmr = dynamic_cast < timer & > ( et ); - this->queue.destroyTimer ( tmr ); -} - epicsTimerForC & timerQueuePassive::createTimerForC ( epicsTimerCallback pCB, void *pPrivateIn ) { return this->queue.createTimerForC ( pCB, pPrivateIn );