From e5b28e846ba0a350d5feda3d2469b48ebb550a22 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 11 Jul 2001 23:31:45 +0000 Subject: [PATCH] adapt to new timer API --- src/ca/repeaterSubscribeTimer.cpp | 4 ++-- src/ca/repeaterSubscribeTimer.h | 5 +++-- src/ca/searchTimer.cpp | 3 ++- src/ca/searchTimer.h | 3 ++- src/ca/tcpRecvWatchdog.cpp | 4 ++-- src/ca/tcpSendWatchdog.cpp | 4 ++-- src/cas/example/simple/exAsyncPV.cc | 8 ++++++-- src/cas/example/simple/exPV.cc | 4 +++- src/cas/example/simple/exServer.cc | 6 +++--- src/cas/generic/caServer.cc | 9 +++++++-- src/cas/generic/casInternal.h | 4 ++-- src/cas/generic/casMonitor.cc | 18 +++++++++--------- src/cas/generic/casdef.h | 1 + src/cas/generic/st/caServerOS.cc | 2 +- src/cas/generic/st/casDGIntfOS.cc | 6 +++--- src/cas/generic/st/casStreamOS.cc | 8 ++++---- src/cas/io/bsdSocket/casStreamIO.cc | 5 ++++- 17 files changed, 56 insertions(+), 38 deletions(-) diff --git a/src/ca/repeaterSubscribeTimer.cpp b/src/ca/repeaterSubscribeTimer.cpp index f012cf18b..ffdfc8f53 100644 --- a/src/ca/repeaterSubscribeTimer.cpp +++ b/src/ca/repeaterSubscribeTimer.cpp @@ -22,7 +22,7 @@ #undef epicsExportSharedSymbols repeaterSubscribeTimer::repeaterSubscribeTimer ( udpiiu &iiuIn, epicsTimerQueue &queueIn ) : - timer ( queueIn.createTimer () ), iiu ( iiuIn ), + queue ( queueIn ), timer ( queueIn.createTimer () ), iiu ( iiuIn ), attempts ( 0 ), registered ( false ), once ( false ) { this->timer.start ( *this, 10.0 ); @@ -30,7 +30,7 @@ repeaterSubscribeTimer::repeaterSubscribeTimer ( udpiiu &iiuIn, epicsTimerQueue repeaterSubscribeTimer::~repeaterSubscribeTimer () { - delete & this->timer; + this->queue.destroyTimer ( this->timer ); } epicsTimerNotify::expireStatus repeaterSubscribeTimer::expire ( const epicsTime & currentTime ) diff --git a/src/ca/repeaterSubscribeTimer.h b/src/ca/repeaterSubscribeTimer.h index 7bef66e9a..6d206607a 100644 --- a/src/ca/repeaterSubscribeTimer.h +++ b/src/ca/repeaterSubscribeTimer.h @@ -24,11 +24,12 @@ class udpiiu; class repeaterSubscribeTimer : private epicsTimerNotify { public: - repeaterSubscribeTimer ( udpiiu &iiu, epicsTimerQueue &queue ); + repeaterSubscribeTimer ( udpiiu &, epicsTimerQueue & ); virtual ~repeaterSubscribeTimer (); void confirmNotify (); - void show (unsigned level) const; + void show ( unsigned level ) const; private: + epicsTimerQueue &queue; epicsTimer &timer; udpiiu &iiu; unsigned attempts; diff --git a/src/ca/searchTimer.cpp b/src/ca/searchTimer.cpp index 514f765da..e08c2ef94 100644 --- a/src/ca/searchTimer.cpp +++ b/src/ca/searchTimer.cpp @@ -37,6 +37,7 @@ static const double maxSearchPeriod = 5.0; // seconds searchTimer::searchTimer ( udpiiu &iiuIn, epicsTimerQueue &queueIn, epicsMutex &mutexIn ) : period ( initialRoundTripEstimate * 2.0 ), roundTripDelayEstimate ( initialRoundTripEstimate ), + queue ( queueIn ), timer ( queueIn.createTimer () ), mutex ( mutexIn ), iiu ( iiuIn ), @@ -57,7 +58,7 @@ searchTimer::searchTimer ( udpiiu &iiuIn, epicsTimerQueue &queueIn, epicsMutex & searchTimer::~searchTimer () { - delete & this->timer; + this->queue.destroyTimer ( this->timer ); } // diff --git a/src/ca/searchTimer.h b/src/ca/searchTimer.h index f1e766138..17f1bad50 100644 --- a/src/ca/searchTimer.h +++ b/src/ca/searchTimer.h @@ -25,7 +25,7 @@ class udpiiu; class searchTimer : private epicsTimerNotify { public: - searchTimer ( udpiiu &iiu, epicsTimerQueue &queue, epicsMutex & ); + searchTimer ( udpiiu &, epicsTimerQueue &, epicsMutex & ); virtual ~searchTimer (); void notifySearchResponse ( unsigned short retrySeqNo, const epicsTime & currentTime ); void resetPeriod ( double delayToNextTry ); @@ -34,6 +34,7 @@ private: epicsTime timeAtLastRetry; double period; /* period between tries */ double roundTripDelayEstimate; + epicsTimerQueue &queue; epicsTimer &timer; epicsMutex &mutex; udpiiu &iiu; diff --git a/src/ca/tcpRecvWatchdog.cpp b/src/ca/tcpRecvWatchdog.cpp index 0f5962c78..7c7734159 100644 --- a/src/ca/tcpRecvWatchdog.cpp +++ b/src/ca/tcpRecvWatchdog.cpp @@ -20,7 +20,7 @@ // tcpRecvWatchdog::tcpRecvWatchdog ( tcpiiu &iiuIn, double periodIn, epicsTimerQueue & queueIn ) : - period ( periodIn ), timer ( queueIn.createTimer () ), + period ( periodIn ), queue ( queueIn ), timer ( queueIn.createTimer () ), iiu ( iiuIn ), responsePending ( false ), beaconAnomaly ( true ) { @@ -28,7 +28,7 @@ tcpRecvWatchdog::tcpRecvWatchdog tcpRecvWatchdog::~tcpRecvWatchdog () { - delete & this->timer; + this->queue.destroyTimer ( this->timer ); } epicsTimerNotify::expireStatus tcpRecvWatchdog::expire ( const epicsTime & /* currentTime */ ) diff --git a/src/ca/tcpSendWatchdog.cpp b/src/ca/tcpSendWatchdog.cpp index 9febe9dc8..9837deaaf 100644 --- a/src/ca/tcpSendWatchdog.cpp +++ b/src/ca/tcpSendWatchdog.cpp @@ -17,14 +17,14 @@ tcpSendWatchdog::tcpSendWatchdog ( tcpiiu &iiuIn, double periodIn, epicsTimerQueue & queueIn ) : - period ( periodIn ), timer ( queueIn.createTimer () ), + period ( periodIn ), queue ( queueIn ), timer ( queueIn.createTimer () ), iiu ( iiuIn ) { } tcpSendWatchdog::~tcpSendWatchdog () { - delete & this->timer; + this->queue.destroyTimer ( this->timer ); } epicsTimerNotify::expireStatus tcpSendWatchdog::expire ( const epicsTime & currentTime ) diff --git a/src/cas/example/simple/exAsyncPV.cc b/src/cas/example/simple/exAsyncPV.cc index 91c1bf8b9..4c905082d 100644 --- a/src/cas/example/simple/exAsyncPV.cc +++ b/src/cas/example/simple/exAsyncPV.cc @@ -67,7 +67,9 @@ exAsyncWriteIO::exAsyncWriteIO ( const casCtx &ctxIn, exAsyncPV &pvIn, exAsyncWriteIO::~exAsyncWriteIO() { this->pv.removeIO(); - delete & this->timer; + if ( this->pv.getCAS() ) { + this->pv.getCAS()->destroyTimer ( this->timer ); + } } // @@ -99,7 +101,9 @@ exAsyncReadIO::exAsyncReadIO ( const casCtx &ctxIn, exAsyncPV &pvIn, exAsyncReadIO::~exAsyncReadIO() { this->pv.removeIO (); - delete & this->timer; + if ( this->pv.getCAS() ) { + this->pv.getCAS()->destroyTimer ( this->timer ); + } } diff --git a/src/cas/example/simple/exPV.cc b/src/cas/example/simple/exPV.cc index afdca22ca..44a449937 100644 --- a/src/cas/example/simple/exPV.cc +++ b/src/cas/example/simple/exPV.cc @@ -48,7 +48,9 @@ exPV::exPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) : // exPV::~exPV() { - delete & this->timer; + if ( this->getCAS() ) { + this->getCAS()->destroyTimer ( this->timer ); + } this->info.unlinkPV(); } diff --git a/src/cas/example/simple/exServer.cc b/src/cas/example/simple/exServer.cc index 7be660670..ab94ad200 100644 --- a/src/cas/example/simple/exServer.cc +++ b/src/cas/example/simple/exServer.cc @@ -328,8 +328,8 @@ exAsyncExistIO::exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn, // exAsyncExistIO::~exAsyncExistIO() { - this->cas.removeIO(); - delete & this->timer; + this->cas.removeIO (); + this->cas.destroyTimer ( this->timer ); } // @@ -364,7 +364,7 @@ exAsyncCreateIO::exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn, exAsyncCreateIO::~exAsyncCreateIO() { this->cas.removeIO (); - delete & this->timer; + this->cas.destroyTimer ( this->timer ); } // diff --git a/src/cas/generic/caServer.cc b/src/cas/generic/caServer.cc index 504029556..2fdf50dfd 100644 --- a/src/cas/generic/caServer.cc +++ b/src/cas/generic/caServer.cc @@ -208,9 +208,14 @@ epicsShareFunc casEventMask caServer::alarmEventMask () const // // caServer::alarmEventMask () // -class epicsTimer & caServer::createTimer() +class epicsTimer & caServer::createTimer () { - return fileDescriptorManager.createTimer(); + return fileDescriptorManager.createTimer (); +} + +void caServer::destroyTimer ( class epicsTimer & tmr ) +{ + fileDescriptorManager.destroyTimer ( tmr ); } // diff --git a/src/cas/generic/casInternal.h b/src/cas/generic/casInternal.h index edd08b2f6..161855da1 100644 --- a/src/cas/generic/casInternal.h +++ b/src/cas/generic/casInternal.h @@ -186,8 +186,8 @@ private: caResId const clientId; unsigned char const dbrType; unsigned char nPend; - unsigned ovf:1; - unsigned enabled:1; + bool ovf; + bool enabled; void enable(); void disable(); diff --git a/src/cas/generic/casMonitor.cc b/src/cas/generic/casMonitor.cc index 4d86652c8..11ff1ff76 100644 --- a/src/cas/generic/casMonitor.cc +++ b/src/cas/generic/casMonitor.cc @@ -51,8 +51,8 @@ casMonitor::casMonitor(caResId clientIdIn, casChannelI &chan, clientId(clientIdIn), dbrType(dbrTypeIn), nPend(0u), - ovf(FALSE), - enabled(FALSE) + ovf(false), + enabled(false) { // // If these are nill it is a programmer error @@ -96,7 +96,7 @@ void casMonitor::enable() this->mutex.lock(); if (!this->enabled && this->ciu.readAccess()) { - this->enabled = TRUE; + this->enabled = true; status = this->ciu.getPVI().registerEvent(); if (status) { errMessage(status, @@ -113,7 +113,7 @@ void casMonitor::disable() { this->mutex.lock(); if (this->enabled) { - this->enabled = FALSE; + this->enabled = false; this->ciu.getPVI().unregisterEvent(); } this->mutex.unlock(); @@ -176,7 +176,7 @@ void casMonitor::push (const smartConstGDDPointer &pNewValue) // no log block // => use the over flow block in the event structure // - this->ovf = TRUE; + this->ovf = true; this->overFlowEvent.assign (*this, pNewValue); this->nPend++; pLog = &this->overFlowEvent; @@ -222,8 +222,8 @@ caStatus casMonitor::executeEvent(casMonEvent *pEV) // saved in the call back object // if (pEV == &this->overFlowEvent) { - assert (this->ovf==TRUE); - this->ovf = FALSE; + assert (this->ovf); + this->ovf = false; pEV->clear(); } else { @@ -241,10 +241,10 @@ caStatus casMonitor::executeEvent(casMonEvent *pEV) void casMonitor::show(unsigned level) const { if (level>1u) { - printf( + printf( "\tmonitor type=%u count=%lu client id=%u enabled=%u OVF=%u nPend=%u\n", dbrType, nElem, clientId, enabled, ovf, nPend); - this->mask.show(level); + this->mask.show(level); } } diff --git a/src/cas/generic/casdef.h b/src/cas/generic/casdef.h index 39c83f2eb..e059d9f24 100644 --- a/src/cas/generic/casdef.h +++ b/src/cas/generic/casdef.h @@ -374,6 +374,7 @@ 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 c8211aed2..f05229315 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 () { - delete & this->timer; + fileDescriptorManager.destroyTimer ( this->timer ); } // diff --git a/src/cas/generic/st/casDGIntfOS.cc b/src/cas/generic/st/casDGIntfOS.cc index deb286ac1..de70af25c 100644 --- a/src/cas/generic/st/casDGIntfOS.cc +++ b/src/cas/generic/st/casDGIntfOS.cc @@ -91,7 +91,7 @@ casDGIntfOS::~casDGIntfOS() // casDGEvWakeup::casDGEvWakeup() // casDGEvWakeup::casDGEvWakeup () : - timer ( fileDescriptorManager.createTimer() ), pOS ( 0 ) + timer ( fileDescriptorManager.createTimer() ), pOS ( 0 ) { } @@ -100,7 +100,7 @@ casDGEvWakeup::casDGEvWakeup () : // casDGEvWakeup::~casDGEvWakeup() { - delete & this->timer; + fileDescriptorManager.destroyTimer ( this->timer ); } void casDGEvWakeup::start ( casDGIntfOS &os ) @@ -148,7 +148,7 @@ casDGIOWakeup::casDGIOWakeup () : // casDGIOWakeup::~casDGIOWakeup() { - delete & this->timer; + fileDescriptorManager.destroyTimer ( this->timer ); } // diff --git a/src/cas/generic/st/casStreamOS.cc b/src/cas/generic/st/casStreamOS.cc index 47fa9d011..beee7eb4b 100644 --- a/src/cas/generic/st/casStreamOS.cc +++ b/src/cas/generic/st/casStreamOS.cc @@ -108,7 +108,7 @@ inline casStreamWriteReg::~casStreamWriteReg () // casStreamEvWakeup() // casStreamEvWakeup::casStreamEvWakeup () : - timer ( fileDescriptorManager.createTimer() ), pOS ( 0 ) + timer ( fileDescriptorManager.createTimer() ), pOS ( 0 ) { } @@ -117,7 +117,7 @@ casStreamEvWakeup::casStreamEvWakeup () : // casStreamEvWakeup::~casStreamEvWakeup() { - delete & this->timer; + fileDescriptorManager.destroyTimer ( this->timer ); } // @@ -185,13 +185,13 @@ casStreamIOWakeup::casStreamIOWakeup () : // casStreamIOWakeup::~casStreamIOWakeup() { - delete & this->timer; + fileDescriptorManager.destroyTimer ( this->timer ); } // // casStreamIOWakeup::show() // -void casStreamIOWakeup::show(unsigned level) const +void casStreamIOWakeup::show ( unsigned level ) const { printf ( "casStreamIOWakeup at %p {\n", static_cast ( this ) ); diff --git a/src/cas/io/bsdSocket/casStreamIO.cc b/src/cas/io/bsdSocket/casStreamIO.cc index 8551987d5..0d63555b2 100644 --- a/src/cas/io/bsdSocket/casStreamIO.cc +++ b/src/cas/io/bsdSocket/casStreamIO.cc @@ -5,6 +5,9 @@ // // // $Log$ +// Revision 1.21 2001/02/16 03:13:27 jhill +// fixed gnu warnings +// // Revision 1.20 2000/04/28 02:23:34 jhill // many, many changes // @@ -281,7 +284,7 @@ xBlockingStatus casStreamIO::blockingState() const bufSizeT casStreamIO::incommingBytesPresent() const { int status; - osiSockIoctl_t nchars; + osiSockIoctl_t nchars = 0; status = socket_ioctl(this->sock, FIONREAD, &nchars); if (status<0) {