From cbabe522e19f15b6012e9d16a9ec3c31a11d1ccb Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 8 Mar 2001 21:32:56 +0000 Subject: [PATCH] osiTimer => epicsTimer --- src/ca/cac.cpp | 16 +- src/ca/iocinf.h | 63 ++++---- src/ca/repeaterSubscribeTimer.cpp | 41 +++-- src/ca/searchTimer.cpp | 41 ++--- src/ca/tcpRecvWatchdog.cpp | 44 ++---- src/ca/tcpSendWatchdog.cpp | 35 ++--- src/cas/example/simple/exAsyncPV.cc | 80 ++++++---- src/cas/example/simple/exPV.cc | 102 +++---------- src/cas/example/simple/exServer.cc | 84 +++++++---- src/cas/example/simple/exServer.h | 222 +++++++--------------------- src/cas/example/simple/main.cc | 10 +- src/cas/generic/st/caServerOS.cc | 55 +++---- src/cas/generic/st/casDGIntfOS.cc | 80 +++++----- src/cas/generic/st/casDGOS.cc | 80 +++------- src/cas/generic/st/casOSD.h | 1 - src/cas/generic/st/casStreamOS.cc | 84 +++++------ 16 files changed, 396 insertions(+), 642 deletions(-) diff --git a/src/ca/cac.cpp b/src/ca/cac.cpp index bb3a5b147..9ae2ec69f 100644 --- a/src/ca/cac.cpp +++ b/src/ca/cac.cpp @@ -55,11 +55,6 @@ cac::cac ( bool enablePreemptiveCallbackIn ) : } } - this->pTimerQueue = new osiTimerQueue ( osiTimerQueue::mtsCreateManagerThread, abovePriority ); - if ( ! this->pTimerQueue ) { - throwWithLocation ( caErrorCode (ECA_ALLOCMEM) ); - } - this->pVPrintfFunc = errlogVprintf; this->ca_exception_func = ca_default_exception_handler; this->ca_exception_arg = NULL; @@ -92,6 +87,12 @@ cac::cac ( bool enablePreemptiveCallbackIn ) : ca_printf ( "Defaulting \"%s\" = %f\n", EPICS_CA_CONN_TMO.name, this->connTMO); } + this->pTimerQueue = & epicsTimerQueueActive::allocate ( false, abovePriority ); + if ( ! this->pTimerQueue ) { + free ( this->pUserName ); + throwWithLocation ( caErrorCode ( ECA_ALLOCMEM ) ); + } + // // unfortunately, this must be created here in the // constructor, and not on demand (only when it is needed) @@ -100,6 +101,8 @@ cac::cac ( bool enablePreemptiveCallbackIn ) : // this->pRecvProcThread = new recvProcessThread ( this ); if ( ! this->pRecvProcThread ) { + this->pTimerQueue->release (); + free ( this->pUserName ); throwWithLocation ( caErrorCode ( ECA_ALLOCMEM ) ); } else if ( this->enablePreemptiveCallback ) { @@ -108,7 +111,6 @@ cac::cac ( bool enablePreemptiveCallbackIn ) : } } - cac::~cac () { this->enableCallbackPreemption (); @@ -192,7 +194,7 @@ cac::~cac () osiSockRelease (); - delete this->pTimerQueue; + this->pTimerQueue->release (); } void cac::processRecvBacklog () diff --git a/src/ca/iocinf.h b/src/ca/iocinf.h index 75d7921c2..1e575feaf 100644 --- a/src/ca/iocinf.h +++ b/src/ca/iocinf.h @@ -46,7 +46,7 @@ #include "osiSock.h" #include "epicsEvent.h" #include "epicsThread.h" -#include "osiTimer.h" +#include "epicsTimer.h" #include "epicsMutex.h" #include "resourceLib.h" #include "localHostName.h" @@ -273,6 +273,7 @@ public: unsigned long nativeElementCount () const; const char *pName () const; unsigned nameLen () const; + bool connected () const; protected: ~nciu (); // force pool allocation private: @@ -309,7 +310,6 @@ private: caar accessRights () const; unsigned searchAttempts () const; double beaconPeriod () const; - bool connected () const; const char * pHostName () const; // deprecated - please do not use void notifyStateChangeFirstConnectInCountOfOutstandingIO (); static tsFreeList < class nciu, 1024 > freeList; @@ -458,7 +458,7 @@ public: void resetChannelRetryCounts (); void attachChannel ( nciu &chan ); void detachChannel ( nciu &chan ); - int installSubscription ( netSubscription &subscr ); + void installSubscription ( netSubscription &subscr ); virtual void hostName (char *pBuf, unsigned bufLength) const; virtual const char * pHostName () const; // deprecated - please do not use virtual bool isVirtaulCircuit ( const char *pChannelName, const osiSockAddr &addr ) const; @@ -483,7 +483,7 @@ private: tsDLList < nciu > channelList; class cac *pClientCtx; virtual void lastChannelDetachNotify (); - virtual int subscriptionRequest ( netSubscription &subscr, bool userThread ); + virtual void subscriptionRequest ( netSubscription &subscr, bool userThread ); }; class limboiiu : public netiiu { @@ -495,13 +495,15 @@ extern limboiiu limboIIU; class udpiiu; -class searchTimer : private osiTimer { +class searchTimer : private epicsTimerNotify { public: - searchTimer ( udpiiu &iiu, osiTimerQueue &queue ); + searchTimer ( udpiiu &iiu, epicsTimerQueue &queue ); + ~searchTimer (); void notifySearchResponse ( unsigned short retrySeqNo ); void resetPeriod ( double delayToNextTry ); void show ( unsigned level ) const; private: + epicsTimer &timer; epicsMutex mutex; udpiiu &iiu; unsigned framesPerTry; /* # of UDP frames per search try */ @@ -513,31 +515,24 @@ private: unsigned short retrySeqNo; /* search retry seq number */ unsigned short retrySeqAtPassBegin; /* search retry seq number at beg of pass through list */ double period; /* period between tries */ - void expire (); - void destroy (); - bool again () const; - double delay () const; - const char *name () const; + expireStatus expire (); void setRetryInterval (unsigned retryNo); }; -class repeaterSubscribeTimer : private osiTimer { +class repeaterSubscribeTimer : private epicsTimerNotify { public: - repeaterSubscribeTimer (udpiiu &iiu, osiTimerQueue &queue); + repeaterSubscribeTimer (udpiiu &iiu, epicsTimerQueue &queue); + ~repeaterSubscribeTimer (); void confirmNotify (); void show (unsigned level) const; private: - void expire (); - void destroy (); - bool again () const; - double delay () const; - const char *name () const; - + epicsTimer &timer; udpiiu &iiu; unsigned attempts; bool registered; bool once; + expireStatus expire (); }; extern "C" void cacRecvThreadUDP (void *pParam); @@ -595,9 +590,9 @@ private: bool repeaterAckAction ( const caHdr &msg, const osiSockAddr &net_addr ); }; -class tcpRecvWatchdog : private osiTimer { +class tcpRecvWatchdog : private epicsTimerNotify { public: - tcpRecvWatchdog ( tcpiiu &, double periodIn, osiTimerQueue & queueIn ); + tcpRecvWatchdog ( tcpiiu &, double periodIn, epicsTimerQueue & queueIn ); ~tcpRecvWatchdog (); void rescheduleRecvTimer (); void messageArrivalNotify (); @@ -608,33 +603,25 @@ public: void show ( unsigned level ) const; private: - void expire (); - void destroy (); - bool again () const; - double delay () const; - const char *name () const; - const double period; + epicsTimer &timer; tcpiiu &iiu; bool responsePending; bool beaconAnomaly; + expireStatus expire (); }; -class tcpSendWatchdog : private osiTimer { +class tcpSendWatchdog : private epicsTimerNotify { public: - tcpSendWatchdog ( tcpiiu &, double periodIn, osiTimerQueue & queueIn ); + tcpSendWatchdog ( tcpiiu &, double periodIn, epicsTimerQueue & queueIn ); ~tcpSendWatchdog (); void start (); void cancel (); private: - void expire (); - void destroy (); - bool again () const; - double delay () const; - const char *name () const; - const double period; + epicsTimer &timer; tcpiiu &iiu; + expireStatus expire (); }; class msgForMultiplyDefinedPV : public ipAddrToAsciiAsynchronous { @@ -679,7 +666,7 @@ class tcpiiu : public netiiu, public tsDLNode < tcpiiu >, private wireSendAdapter, private wireRecvAdapter { public: - tcpiiu ( cac &cac, double connectionTimeout, osiTimerQueue &timerQueue ); + tcpiiu ( cac &cac, double connectionTimeout, epicsTimerQueue &timerQueue ); ~tcpiiu (); bool initiateConnect ( const osiSockAddr &addrIn, unsigned minorVersion, class bhe &bhe, ipAddrToAsciiEngine &engineIn ); @@ -793,7 +780,7 @@ private: bool uninstallIO ( baseNMIU & ); bool destroyAllIO ( nciu &chan ); - int subscriptionRequest ( netSubscription &subscr, bool userThread ); + void subscriptionRequest ( netSubscription &subscr, bool userThread ); void subscriptionCancelRequest ( netSubscription &subscr, bool userThread ); typedef bool ( tcpiiu::*pProtoStubTCP ) (); @@ -1069,7 +1056,7 @@ private: mutable epicsMutex defaultMutex; // iiuListMutex must not be applied if defaultMutex is already applied mutable epicsMutex iiuListMutex; - osiTimerQueue *pTimerQueue; + epicsTimerQueueActive *pTimerQueue; caExceptionHandler *ca_exception_func; void *ca_exception_arg; caPrintfFunc *pVPrintfFunc; diff --git a/src/ca/repeaterSubscribeTimer.cpp b/src/ca/repeaterSubscribeTimer.cpp index 16ac7e40a..afe69b631 100644 --- a/src/ca/repeaterSubscribeTimer.cpp +++ b/src/ca/repeaterSubscribeTimer.cpp @@ -14,12 +14,19 @@ #include "iocinf.h" -repeaterSubscribeTimer::repeaterSubscribeTimer ( udpiiu &iiuIn, osiTimerQueue &queueIn ) : - osiTimer ( 10.0, queueIn ), iiu ( iiuIn ), attempts ( 0 ), registered ( false ), once (false) +repeaterSubscribeTimer::repeaterSubscribeTimer ( udpiiu &iiuIn, epicsTimerQueue &queueIn ) : + timer ( queueIn.createTimer ( *this ) ), iiu ( iiuIn ), + attempts ( 0 ), registered ( false ), once ( false ) { + this->timer.start ( 10.0 ); } -void repeaterSubscribeTimer::expire () +repeaterSubscribeTimer::~repeaterSubscribeTimer () +{ + delete & this->timer; +} + +epicsTimerNotify::expireStatus repeaterSubscribeTimer::expire () { static const unsigned nTriesToMsg = 50; if ( this->attempts > nTriesToMsg && ! this->once ) { @@ -32,31 +39,19 @@ void repeaterSubscribeTimer::expire () this->iiu.repeaterRegistrationMessage ( this->attempts ); this->attempts++; + + if ( this->registered ) { + return noRestart; + } + else { + return expireStatus ( restart, 1.0 ); + } } -void repeaterSubscribeTimer::destroy () +void repeaterSubscribeTimer::show ( unsigned /* level */ ) const { } -bool repeaterSubscribeTimer::again () const -{ - return ( ! this->registered ); -} - -double repeaterSubscribeTimer::delay () const -{ - return 1.0; -} - -void repeaterSubscribeTimer::show (unsigned /* level */ ) const -{ -} - -const char *repeaterSubscribeTimer::name () const -{ - return "repeaterSubscribeTimer"; -} - void repeaterSubscribeTimer::confirmNotify () { this->registered = true; diff --git a/src/ca/searchTimer.cpp b/src/ca/searchTimer.cpp index daa657de2..724dae797 100644 --- a/src/ca/searchTimer.cpp +++ b/src/ca/searchTimer.cpp @@ -18,8 +18,8 @@ // // searchTimer::searchTimer () // -searchTimer::searchTimer ( udpiiu &iiuIn, osiTimerQueue &queueIn ) : - osiTimer ( queueIn ), +searchTimer::searchTimer ( udpiiu &iiuIn, epicsTimerQueue &queueIn ) : + timer ( queueIn.createTimer ( *this ) ), iiu ( iiuIn ), framesPerTry ( INITIALTRIESPERFRAME ), framesPerTryCongestThresh ( UINT_MAX ), @@ -33,6 +33,11 @@ searchTimer::searchTimer ( udpiiu &iiuIn, osiTimerQueue &queueIn ) : { } +searchTimer::~searchTimer () +{ + delete & this->timer; +} + // // searchTimer::resetPeriod () // @@ -57,11 +62,11 @@ void searchTimer::resetPeriod ( double delayToNextTry ) } if ( reschedule ) { - this->reschedule ( delayToNextTry ); + this->timer.start ( delayToNextTry ); debugPrintf ( ("rescheduled search timer for completion in %f sec\n", delayToNextTry) ); } else { - this->activate ( delayToNextTry ); + this->timer.start ( delayToNextTry ); debugPrintf ( ("if inactive, search timer started to completion in %f sec\n", delayToNextTry) ); } } @@ -119,14 +124,14 @@ void searchTimer::notifySearchResponse ( unsigned short retrySeqNoIn ) } if ( reschedualNeeded ) { - this->reschedule ( 0.0 ); + this->timer.start ( 0.0 ); } } // // searchTimer::expire () // -void searchTimer::expire () +epicsTimerNotify::expireStatus searchTimer::expire () { unsigned nFrameSent = 0u; unsigned nChanSent = 0u; @@ -135,7 +140,7 @@ void searchTimer::expire () * check to see if there is nothing to do here */ if ( this->iiu.channelCount () == 0 ) { - return; + return noRestart; } { @@ -298,35 +303,19 @@ void searchTimer::expire () this->iiu.flush (); debugPrintf ( ("sent %u delay sec=%f\n", nFrameSent, this->period) ); -} -void searchTimer::destroy () -{ -} - -bool searchTimer::again () const -{ if ( this->iiu.channelCount () == 0 ) { - return false; + return noRestart; } else if ( this->retry < MAXCONNTRIES ) { - return true; + return expireStatus ( restart, this->period ); } else { - return false; + return noRestart; } } -double searchTimer::delay () const -{ - return this->period; -} - void searchTimer::show ( unsigned /* level */ ) const { } -const char *searchTimer::name () const -{ - return "CAC Search Timer"; -} diff --git a/src/ca/tcpRecvWatchdog.cpp b/src/ca/tcpRecvWatchdog.cpp index 1242f2e59..3b0859d79 100644 --- a/src/ca/tcpRecvWatchdog.cpp +++ b/src/ca/tcpRecvWatchdog.cpp @@ -16,18 +16,19 @@ // the recv watchdog timer is active when this object is created // tcpRecvWatchdog::tcpRecvWatchdog - ( tcpiiu &iiuIn, double periodIn, osiTimerQueue & queueIn ) : - osiTimer ( queueIn ), - period ( periodIn ), iiu ( iiuIn ), responsePending ( false ), + ( tcpiiu &iiuIn, double periodIn, epicsTimerQueue & queueIn ) : + period ( periodIn ), timer ( queueIn.createTimer ( *this ) ), + iiu ( iiuIn ), responsePending ( false ), beaconAnomaly ( true ) { } tcpRecvWatchdog::~tcpRecvWatchdog () { + delete & this->timer; } -void tcpRecvWatchdog::expire () +epicsTimerNotify::expireStatus tcpRecvWatchdog::expire () { if ( this->responsePending ) { this->cancel (); @@ -36,37 +37,19 @@ void tcpRecvWatchdog::expire () ca_printf ( "CA server \"%s\" unresponsive after %g inactive sec - disconnecting.\n", hostName, this->period ); this->iiu.forcedShutdown (); + return noRestart; } else { this->responsePending = this->iiu.setEchoRequestPending (); debugPrintf ( ("TCP connection timed out - sending echo request\n") ); - } -} - -void tcpRecvWatchdog::destroy () -{ - // ignore timer destroy requests -} - -bool tcpRecvWatchdog::again () const -{ - return true; -} - -double tcpRecvWatchdog::delay () const -{ - if ( this->responsePending ) { - return CA_ECHO_TIMEOUT; - } - else { - return this->period; + return expireStatus ( restart, CA_ECHO_TIMEOUT ); } } void tcpRecvWatchdog::beaconArrivalNotify () { if ( ! this->beaconAnomaly && ! this->responsePending ) { - this->reschedule ( this->period ); + this->timer.start ( this->period ); debugPrintf ( ("Saw a normal beacon - reseting TCP recv watchdog\n") ); } } @@ -88,24 +71,19 @@ void tcpRecvWatchdog::messageArrivalNotify () { this->beaconAnomaly = false; this->responsePending = false; - this->reschedule ( this->period ); + this->timer.start ( this->period ); debugPrintf ( ("received a message - reseting TCP recv watchdog\n") ); } void tcpRecvWatchdog::connectNotify () { - this->reschedule ( this->period ); + this->timer.start ( this->period ); debugPrintf ( ("connected to the server - reseting TCP recv watchdog\n") ); } -const char *tcpRecvWatchdog::name () const -{ - return "TCP Receive Watchdog"; -} - void tcpRecvWatchdog::cancel () { - this->osiTimer::cancel (); + this->timer.cancel (); debugPrintf ( ("canceling TCP recv watchdog\n") ); } diff --git a/src/ca/tcpSendWatchdog.cpp b/src/ca/tcpSendWatchdog.cpp index e04f40719..d05db9cd7 100644 --- a/src/ca/tcpSendWatchdog.cpp +++ b/src/ca/tcpSendWatchdog.cpp @@ -13,51 +13,34 @@ #include "iocinf.h" tcpSendWatchdog::tcpSendWatchdog - ( tcpiiu &iiuIn, double periodIn, osiTimerQueue & queueIn ) : - osiTimer ( queueIn ), period ( periodIn ), iiu ( iiuIn ) + ( tcpiiu &iiuIn, double periodIn, epicsTimerQueue & queueIn ) : + period ( periodIn ), timer ( queueIn.createTimer ( *this ) ), + iiu ( iiuIn ) { } tcpSendWatchdog::~tcpSendWatchdog () { + delete & this->timer; } -void tcpSendWatchdog::expire () +epicsTimerNotify::expireStatus tcpSendWatchdog::expire () { char hostName[128]; - this->iiu.hostName ( hostName, sizeof (hostName) ); + this->iiu.hostName ( hostName, sizeof ( hostName ) ); ca_printf ( "Request not accepted by CA server %s for %g sec. Disconnecting.\n", hostName, this->period ); this->iiu.forcedShutdown (); -} - -void tcpSendWatchdog::destroy () -{ - // ignore timer destroy requests -} - -bool tcpSendWatchdog::again () const -{ - return false; // a one shot -} - -double tcpSendWatchdog::delay () const -{ - return this->period; -} - -const char *tcpSendWatchdog::name () const -{ - return "TCP Send Watchdog"; + return noRestart; } void tcpSendWatchdog::start () { - this->osiTimer::reschedule (); + this->timer.start ( this->period ); } void tcpSendWatchdog::cancel () { - this->osiTimer::cancel (); + this->timer.cancel (); } diff --git a/src/cas/example/simple/exAsyncPV.cc b/src/cas/example/simple/exAsyncPV.cc index 97af45975..547ce73e0 100644 --- a/src/cas/example/simple/exAsyncPV.cc +++ b/src/cas/example/simple/exAsyncPV.cc @@ -20,7 +20,7 @@ caStatus exAsyncPV::read (const casCtx &ctx, gdd &valueIn) this->simultAsychIOCount++; - pIO = new exAsyncReadIO(ctx, *this, valueIn); + pIO = new exAsyncReadIO ( ctx, *this, valueIn ); if (!pIO) { return S_casApp_noMemory; } @@ -32,18 +32,18 @@ caStatus exAsyncPV::read (const casCtx &ctx, gdd &valueIn) // exAsyncPV::write() // (virtual replacement for the default) // -caStatus exAsyncPV::write (const casCtx &ctx, const gdd &valueIn) +caStatus exAsyncPV::write ( const casCtx &ctx, const gdd &valueIn ) { - exAsyncWriteIO *pIO; + exAsyncWriteIO *pIO; - if (this->simultAsychIOCount>=maxSimultAsyncIO) { + if ( this->simultAsychIOCount >= maxSimultAsyncIO ) { return S_casApp_postponeAsyncIO; } this->simultAsychIOCount++; - pIO = new exAsyncWriteIO(ctx, *this, valueIn); - if (!pIO) { + pIO = new exAsyncWriteIO ( ctx, *this, valueIn ); + if ( ! pIO ) { return S_casApp_noMemory; } @@ -51,29 +51,63 @@ caStatus exAsyncPV::write (const casCtx &ctx, const gdd &valueIn) } // -// exAsyncWriteIO::expire() -// (a virtual function that runs when the base timer expires) +// exAsyncWriteIO::exAsyncWriteIO() // -void exAsyncWriteIO::expire() +exAsyncWriteIO::exAsyncWriteIO ( const casCtx &ctxIn, exAsyncPV &pvIn, + const gdd &valueIn ) : + casAsyncWriteIO ( ctxIn ), pv ( pvIn ), + timer ( pvIn.getCAS()->timerQueue().createTimer ( *this ) ), pValue(valueIn) { - caStatus status; - status = this->pv.update(this->pValue); - this->postIOCompletion (status); + this->timer.start ( 0.1 ); } // -// exAsyncWriteIO::name() +// exAsyncWriteIO::~exAsyncWriteIO() // -const char *exAsyncWriteIO::name() const +exAsyncWriteIO::~exAsyncWriteIO() { - return "exAsyncWriteIO"; + this->pv.removeIO(); + delete & this->timer; } +// +// exAsyncWriteIO::expire() +// (a virtual function that runs when the base timer expires) +// +epicsTimerNotify::expireStatus exAsyncWriteIO::expire () +{ + caStatus status; + status = this->pv.update ( this->pValue ); + this->postIOCompletion ( status ); + return noRestart; +} + +// +// exAsyncReadIO::exAsyncReadIO() +// +exAsyncReadIO::exAsyncReadIO ( const casCtx &ctxIn, exAsyncPV &pvIn, + gdd &protoIn ) : + casAsyncReadIO ( ctxIn ), pv ( pvIn ), + timer ( pvIn.getCAS()->timerQueue().createTimer(*this) ), pProto ( protoIn ) +{ + this->timer.start ( 0.1 ); +} + +// +// exAsyncReadIO::~exAsyncReadIO() +// +exAsyncReadIO::~exAsyncReadIO() +{ + this->pv.removeIO (); + delete & this->timer; +} + + // // exAsyncReadIO::expire() // (a virtual function that runs when the base timer expires) // -void exAsyncReadIO::expire () +epicsTimerNotify::expireStatus exAsyncReadIO::expire () { caStatus status; @@ -81,19 +115,13 @@ void exAsyncReadIO::expire () // map between the prototype in and the // current value // - status = this->pv.exPV::readNoCtx (this->pProto); + status = this->pv.exPV::readNoCtx ( this->pProto ); // // post IO completion // - this->postIOCompletion (status, *this->pProto ); -} - -// -// exAsyncReadIO::name() -// -const char *exAsyncReadIO::name() const -{ - return "exAsyncReadIO"; + this->postIOCompletion ( status, *this->pProto ); + + return noRestart; } diff --git a/src/cas/example/simple/exPV.cc b/src/cas/example/simple/exPV.cc index 48464b30c..0abd79863 100644 --- a/src/cas/example/simple/exPV.cc +++ b/src/cas/example/simple/exPV.cc @@ -21,11 +21,12 @@ class exFixedStringDestructor: public gddDestructor { // // exPV::exPV() // -exPV::exPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) : - info (setup), - interest (false), - preCreate (preCreateFlag), - scanOn (scanOnIn) +exPV::exPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) : + timer ( this->getCAS()->timerQueue().createTimer(*this) ), + info ( setup ), + interest ( false ), + preCreate ( preCreateFlag ), + scanOn ( scanOnIn ) { // // no dataless PV allowed @@ -38,12 +39,8 @@ exPV::exPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) : // someone is watching the PV) // if ( this->scanOn && this->info.getScanPeriod () > 0.0 ) { - this->pScanTimer = - new exScanTimer (this->getScanPeriod(), *this); + this->timer.start ( this->getScanPeriod() ); } - else { - this->pScanTimer = 0; - } } // @@ -51,10 +48,7 @@ exPV::exPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) : // exPV::~exPV() { - if (this->pScanTimer) { - delete this->pScanTimer; - this->pScanTimer = NULL; - } + delete & this->timer; this->info.unlinkPV(); } @@ -66,7 +60,7 @@ exPV::~exPV() // void exPV::destroy() { - if (!this->preCreate) { + if ( ! this->preCreate ) { delete this; } } @@ -100,44 +94,18 @@ caStatus exPV::update(smartConstGDDPointer pValueIn) return S_casApp_success; } -// -// exScanTimer::~exScanTimer () -// -exScanTimer::~exScanTimer () -{ - pv.pScanTimer = NULL; -} - // // exScanTimer::expire () // -void exScanTimer::expire () +epicsTimerNotify::expireStatus exPV::expire () { - pv.scan(); -} - -// -// exScanTimer::again() -// -bool exScanTimer::again() const -{ - return true; -} - -// -// exScanTimer::delay() -// -double exScanTimer::delay() const -{ - return pv.getScanPeriod(); -} - -// -// exScanTimer::name() -// -const char *exScanTimer::name() const -{ - return "exScanTimer"; + this->scan(); + if ( this->scanOn ) { + return expireStatus ( restart, this->getScanPeriod() ); + } + else { + return noRestart; + } } // @@ -153,34 +121,16 @@ aitEnum exPV::bestExternalType() const // caStatus exPV::interestRegister() { - caServer *pCAS = this->getCAS(); + caServer *pCAS = this->getCAS(); - if (!pCAS) { + if ( ! pCAS ) { return S_casApp_success; } this->interest = true; - if (!this->scanOn) { - return S_casApp_success; - } - - // - // If a slow scan is pending then reschedule it - // with the specified scan period. - // - if (this->pScanTimer) { - this->pScanTimer->reschedule(this->getScanPeriod()); - } - else if ( this->getScanPeriod () > 0.0 ) { - this->pScanTimer = new exScanTimer - (this->getScanPeriod(), *this); - if (!this->pScanTimer) { - errPrintf (S_cas_noMemory, __FILE__, __LINE__, - "Scan init for %s failed\n", - this->info.getName()); - return S_cas_noMemory; - } + if ( this->scanOn && this->getScanPeriod() < this->timer.getExpireDelay() ) { + this->timer.start ( this->getScanPeriod() ); } return S_casApp_success; @@ -192,15 +142,12 @@ caStatus exPV::interestRegister() void exPV::interestDelete() { this->interest = false; - if (this->pScanTimer && this->scanOn) { - this->pScanTimer->reschedule(this->getScanPeriod()); - } } // // exPV::show() // -void exPV::show(unsigned level) const +void exPV::show ( unsigned level ) const { if (level>1u) { if ( this->pValue.valid () ) { @@ -209,8 +156,7 @@ void exPV::show(unsigned level) const printf ( "exPV: value=%f\n", static_cast < double > ( * this->pValue ) ); } printf ( "exPV: interest=%d\n", this->interest ); - printf ( "exPV: pScanTimer=%p\n", - static_cast < const void * > ( this->pScanTimer ) ); + this->timer.show ( level - 1u ); } } @@ -219,7 +165,7 @@ void exPV::show(unsigned level) const // void exPV::initFT() { - if (exPV::hasBeenInitialized) { + if ( exPV::hasBeenInitialized ) { return; } diff --git a/src/cas/example/simple/exServer.cc b/src/cas/example/simple/exServer.cc index 06930c84a..7dbe966d9 100644 --- a/src/cas/example/simple/exServer.cc +++ b/src/cas/example/simple/exServer.cc @@ -47,7 +47,8 @@ pvInfo exServer::billy (-1.0, "billy", 10.0f, -10.0f, excasIoAsync, 1u); // // exServer::exServer() // -exServer::exServer(const char * const pvPrefix, unsigned aliasCount, bool scanOnIn) : +exServer::exServer ( const char * const pvPrefix, + unsigned aliasCount, bool scanOnIn ) : caServer (pvListNElem+2u), stringResTbl (pvListNElem*(aliasCount+1u)+2u), simultAsychIOCount (0u), @@ -176,7 +177,7 @@ pvExistReturn exServer::pvExistTest this->simultAsychIOCount++; exAsyncExistIO *pIO; - pIO = new exAsyncExistIO(pvi, ctxIn, *this); + pIO = new exAsyncExistIO ( pvi, ctxIn, *this ); if (pIO) { return pverAsyncCompletion; } @@ -242,7 +243,7 @@ pvAttachReturn exServer::pvAttach // // pvInfo::createPV() // -exPV *pvInfo::createPV (exServer &, bool preCreateFlag, bool scanOn) +exPV *pvInfo::createPV ( exServer &cas, bool preCreateFlag, bool scanOn ) { if (this->pPV) { return this->pPV; @@ -258,10 +259,10 @@ exPV *pvInfo::createPV (exServer &, bool preCreateFlag, bool scanOn) if (this->elementCount==1u) { switch (this->ioType){ case excasIoSync: - pNewPV = new exScalarPV (*this, preCreateFlag, scanOn); + pNewPV = new exScalarPV ( *this, preCreateFlag, scanOn ); break; case excasIoAsync: - pNewPV = new exAsyncPV (*this, preCreateFlag, scanOn); + pNewPV = new exAsyncPV ( *this, preCreateFlag, scanOn ); break; default: pNewPV = NULL; @@ -269,8 +270,8 @@ exPV *pvInfo::createPV (exServer &, bool preCreateFlag, bool scanOn) } } else { - if (this->ioType==excasIoSync) { - pNewPV = new exVectorPV (*this, preCreateFlag, scanOn); + if ( this->ioType == excasIoSync ) { + pNewPV = new exVectorPV ( *this, preCreateFlag, scanOn ); } else { pNewPV = NULL; @@ -312,56 +313,75 @@ void exServer::show (unsigned level) const } // -// this is a noop that postpones the timer expiration -// destroy so the exAsyncIO class will hang around until the -// casAsyncIO::destroy() is called +// exAsyncExistIO::exAsyncExistIO() // -void exOSITimer::destroy() +exAsyncExistIO::exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn, + exServer &casIn ) : + casAsyncPVExistIO ( ctxIn ), pvi ( pviIn ), + timer ( casIn.timerQueue().createTimer ( *this ) ), cas ( casIn ) { + this->timer.start ( 0.00001 ); +} + +// +// exAsyncExistIO::~exAsyncExistIO() +// +exAsyncExistIO::~exAsyncExistIO() +{ + this->cas.removeIO(); + delete & this->timer; } // // exAsyncExistIO::expire() // (a virtual function that runs when the base timer expires) // -void exAsyncExistIO::expire() +epicsTimerNotify::expireStatus exAsyncExistIO::expire () { - // - // post IO completion - // - this->postIOCompletion (pvExistReturn(pverExistsHere)); + // + // post IO completion + // + this->postIOCompletion ( pvExistReturn(pverExistsHere) ); + return noRestart; +} + + +// +// exAsyncCreateIO::exAsyncCreateIO() +// +exAsyncCreateIO::exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn, + const casCtx &ctxIn, bool scanOnIn ) : + casAsyncPVAttachIO ( ctxIn ), pvi ( pviIn ), + timer ( casIn.timerQueue().createTimer ( *this ) ), + cas ( casIn ), scanOn ( scanOnIn ) +{ + this->timer.start ( 0.00001 ); } // -// exAsyncExistIO::name() +// exAsyncCreateIO::~exAsyncCreateIO() // -const char *exAsyncExistIO::name() const +exAsyncCreateIO::~exAsyncCreateIO() { - return "exAsyncExistIO"; + this->cas.removeIO (); + delete & this->timer; } // // exAsyncCreateIO::expire() // (a virtual function that runs when the base timer expires) // -void exAsyncCreateIO::expire() +epicsTimerNotify::expireStatus exAsyncCreateIO::expire () { exPV *pPV; - pPV = this->pvi.createPV(this->cas, false, this->scanOn); - if (pPV) { - this->postIOCompletion (pvAttachReturn(*pPV)); + pPV = this->pvi.createPV ( this->cas, false, this->scanOn ); + if ( pPV ) { + this->postIOCompletion ( pvAttachReturn ( *pPV ) ); } else { - this->postIOCompletion (pvAttachReturn(S_casApp_noMemory)); + this->postIOCompletion ( pvAttachReturn ( S_casApp_noMemory ) ); } -} - -// -// exAsyncCreateIO::name() -// -const char *exAsyncCreateIO::name() const -{ - return "exAsyncCreateIO"; + return noRestart; } diff --git a/src/cas/example/simple/exServer.h b/src/cas/example/simple/exServer.h index a30a333f2..a923e70ec 100644 --- a/src/cas/example/simple/exServer.h +++ b/src/cas/example/simple/exServer.h @@ -29,10 +29,10 @@ // // EPICS // +#include "epicsTimer.h" #include "casdef.h" #include "epicsAssert.h" #include "gddAppFuncTable.h" -#include "osiTimer.h" #include "resourceLib.h" #include "tsMinMax.h" @@ -130,35 +130,16 @@ private: exServer &cas; }; -// -// exScanTimer -// -class exScanTimer : public osiTimer { -public: - exScanTimer (double delayIn, exPV &pvIn) : - osiTimer(delayIn), pv(pvIn) {} - ~exScanTimer(); - void expire (); - bool again() const; - double delay() const; - const char *name() const; -private: - exPV &pv; -}; - - // // exPV // -class exPV : public casPV, public tsSLNode { - // allow the exScanTimer destructor to set dangling pScanTimer pointer to NULL - friend exScanTimer::~exScanTimer(); +class exPV : public casPV, public epicsTimerNotify, public tsSLNode { public: - exPV (pvInfo &setup, bool preCreateFlag, bool scanOn); + exPV ( pvInfo &setup, bool preCreateFlag, bool scanOn ); virtual ~exPV(); - void show(unsigned level) const; + void show ( unsigned level ) const; // // Called by the server libary each time that it wishes to @@ -204,8 +185,8 @@ public: { double curPeriod; - curPeriod = this->info.getScanPeriod(); - if (!this->interest) { + curPeriod = this->info.getScanPeriod (); + if ( ! this->interest ) { curPeriod *= 10.0L; } return curPeriod; @@ -242,7 +223,7 @@ public: protected: smartConstGDDPointer pValue; - exScanTimer *pScanTimer; + epicsTimer &timer; pvInfo & info; bool interest; bool preCreate; @@ -252,6 +233,12 @@ protected: virtual caStatus updateValue (smartConstGDDPointer pValue) = 0; private: + + // + // scan timer expire + // + expireStatus expire (); + // // Std PV Attribute fetch support // @@ -274,8 +261,8 @@ private: // class exScalarPV : public exPV { public: - exScalarPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) : - exPV (setup, preCreateFlag, scanOnIn) {} + exScalarPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) : + exPV ( setup, preCreateFlag, scanOnIn) {} void scan(); private: caStatus updateValue (smartConstGDDPointer pValue); @@ -286,8 +273,8 @@ private: // class exVectorPV : public exPV { public: - exVectorPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) : - exPV (setup, preCreateFlag, scanOnIn) {} + exVectorPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) : + exPV ( setup, preCreateFlag, scanOnIn) {} void scan(); unsigned maxDimension() const; @@ -302,7 +289,8 @@ private: // class exServer : public caServer { public: - exServer(const char * const pvPrefix, unsigned aliasCount, bool scanOn); + exServer ( const char * const pvPrefix, + unsigned aliasCount, bool scanOn ); ~exServer(); void show (unsigned level) const; @@ -352,9 +340,9 @@ public: // // exAsyncPV() // - exAsyncPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) : - exScalarPV (setup, preCreateFlag, scanOnIn), - simultAsychIOCount(0u) {} + exAsyncPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) : + exScalarPV ( setup, preCreateFlag, scanOnIn ), + simultAsychIOCount ( 0u ) {} // // read @@ -398,120 +386,48 @@ public: private: }; -// -// exOSITimer -// -// a special version of osiTimer which is only to be used -// within an exAsyncIO. The destroy() method is replaced -// so that the timer destroy() will not destroy the -// exAsyncIO until the casAsyncIO has completed -// -class exOSITimer : public osiTimer { -public: - exOSITimer (double delay) : osiTimer(delay) {} - - // - // this is a noop that postpones the timer expiration - // destroy so this object will hang around until the - // casAsyncIO::destroy() is called - // - void destroy(); -}; - - // // exAsyncWriteIO // -class exAsyncWriteIO : public casAsyncWriteIO, public exOSITimer { +class exAsyncWriteIO : public casAsyncWriteIO, public epicsTimerNotify { public: - // - // exAsyncWriteIO() - // - exAsyncWriteIO (const casCtx &ctxIn, exAsyncPV &pvIn, const gdd &valueIn) : - casAsyncWriteIO(ctxIn), exOSITimer(0.1), pv(pvIn), pValue(valueIn) - { - } - - ~exAsyncWriteIO() - { - this->pv.removeIO(); - } - - // - // expire() - // (a virtual function that runs when the base timer expires) - // see exAsyncPV.cc - // - void expire(); - - const char *name() const; - + exAsyncWriteIO ( const casCtx &ctxIn, exAsyncPV &pvIn, const gdd &valueIn ); + ~exAsyncWriteIO (); private: - exAsyncPV &pv; - smartConstGDDPointer pValue; + exAsyncPV &pv; + epicsTimer &timer; + smartConstGDDPointer pValue; + expireStatus expire (); }; // // exAsyncReadIO // -class exAsyncReadIO : public casAsyncReadIO, public exOSITimer { +class exAsyncReadIO : public casAsyncReadIO, public epicsTimerNotify { public: - // - // exAsyncReadIO() - // - exAsyncReadIO(const casCtx &ctxIn, exAsyncPV &pvIn, gdd &protoIn) : - casAsyncReadIO(ctxIn), exOSITimer(0.1), pv(pvIn), pProto(protoIn) - { - } - - ~exAsyncReadIO() - { - this->pv.removeIO(); - } - - // - // expire() - // (a virtual function that runs when the base timer expires) - // see exAsyncPV.cc - // - void expire(); - - const char *name() const; - + exAsyncReadIO ( const casCtx &ctxIn, exAsyncPV &pvIn, gdd &protoIn ); + ~exAsyncReadIO (); private: - exAsyncPV &pv; - smartGDDPointer pProto; + exAsyncPV &pv; + epicsTimer &timer; + smartGDDPointer pProto; + expireStatus expire (); }; // // exAsyncExistIO // (PV exist async IO) // -class exAsyncExistIO : public casAsyncPVExistIO, public exOSITimer { +class exAsyncExistIO : public casAsyncPVExistIO, public epicsTimerNotify { public: - // - // exAsyncExistIO() - // - exAsyncExistIO(const pvInfo &pviIn, const casCtx &ctxIn, - exServer &casIn) : - casAsyncPVExistIO(ctxIn), exOSITimer(0.00001), pvi(pviIn), cas(casIn) {} - - ~exAsyncExistIO() - { - this->cas.removeIO(); - } - - // - // expire() - // (a virtual function that runs when the base timer expires) - // see exServer.cc - // - void expire(); - - const char *name() const; + exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn, + exServer &casIn ); + ~exAsyncExistIO (); private: - const pvInfo &pvi; - exServer &cas; + const pvInfo &pvi; + epicsTimer &timer; + exServer &cas; + expireStatus expire (); }; @@ -519,43 +435,27 @@ private: // exAsyncCreateIO // (PV create async IO) // -class exAsyncCreateIO : public casAsyncPVAttachIO, public exOSITimer { +class exAsyncCreateIO : public casAsyncPVAttachIO, public epicsTimerNotify { public: - // - // exAsyncCreateIO() - // - exAsyncCreateIO(pvInfo &pviIn, exServer &casIn, - const casCtx &ctxIn, bool scanOnIn) : - casAsyncPVAttachIO(ctxIn), exOSITimer(0.00001), - pvi(pviIn), cas(casIn), scanOn(scanOnIn) {} - - ~exAsyncCreateIO() - { - this->cas.removeIO(); - } - - // - // expire() - // (a virtual function that runs when the base timer expires) - // see exServer.cc - // - void expire(); - - const char *name() const; + exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn, + const casCtx &ctxIn, bool scanOnIn ); + ~exAsyncCreateIO (); private: pvInfo &pvi; + epicsTimer &timer; exServer &cas; bool scanOn; + expireStatus expire (); }; // // exServer::removeAliasName() // -inline void exServer::removeAliasName(pvEntry &entry) +inline void exServer::removeAliasName ( pvEntry &entry ) { pvEntry *pE; - pE = this->stringResTbl.remove(entry); - assert(pE = &entry); + pE = this->stringResTbl.remove ( entry ); + assert ( pE == &entry ); } // @@ -563,7 +463,7 @@ inline void exServer::removeAliasName(pvEntry &entry) // inline pvEntry::~pvEntry() { - this->cas.removeAliasName(*this); + this->cas.removeAliasName ( *this ); } // @@ -571,28 +471,20 @@ inline pvEntry::~pvEntry() // inline void pvEntry::destroy () { - // - // always created with new (in this example) - // delete this; } inline pvInfo::~pvInfo () { - // - // dont leak pre created PVs when we exit - // - if (this->pPV!=NULL) { - // - // always created with new (in this example) - // + if ( this->pPV != NULL ) { delete this->pPV; } } inline void pvInfo::deletePV () { - if (this->pPV!=NULL) { + if ( this->pPV != NULL ) { delete this->pPV; } } + diff --git a/src/cas/example/simple/main.cc b/src/cas/example/simple/main.cc index a6175e14b..c6acd0ff7 100644 --- a/src/cas/example/simple/main.cc +++ b/src/cas/example/simple/main.cc @@ -51,14 +51,14 @@ extern int main (int argc, const char **argv) scanOn = false; } - pCAS = new exServer (pvPrefix, aliasCount, scanOn); - if (!pCAS) { + pCAS = new exServer ( pvPrefix, aliasCount, scanOn ); + if ( ! pCAS ) { return (-1); } pCAS->setDebugLevel(debugLevel); - if (forever) { + if ( forever ) { // // loop here forever // @@ -72,8 +72,8 @@ extern int main (int argc, const char **argv) // loop here untill the specified execution time // expires // - while (delay < executionTime) { - fileDescriptorManager.process(delay); + while ( delay < executionTime ) { + fileDescriptorManager.process ( delay ); delay = epicsTime::getCurrent() - begin; } } diff --git a/src/cas/generic/st/caServerOS.cc b/src/cas/generic/st/caServerOS.cc index 44c879e38..0f3b74b6c 100644 --- a/src/cas/generic/st/caServerOS.cc +++ b/src/cas/generic/st/caServerOS.cc @@ -11,22 +11,32 @@ // CA server // #include "server.h" +#include "fdManager.h" // // casBeaconTimer // -class casBeaconTimer : public osiTimer { +class casBeaconTimer : public epicsTimerNotify { public: - casBeaconTimer (double delay, caServerOS &osIn) : - osiTimer(delay), os (osIn) {} - void expire(); - double delay() const; - bool again() const; - const char *name() const; + casBeaconTimer ( double delay, caServerOS &osIn ); + ~casBeaconTimer (); private: - caServerOS &os; + epicsTimer &timer; + caServerOS &os; + expireStatus expire (); }; +casBeaconTimer::casBeaconTimer ( double delay, caServerOS &osIn ) : + timer ( fileDescriptorManager.timerQueueRef().createTimer(*this) ), os ( osIn ) +{ + this->timer.start ( delay ); +} + +casBeaconTimer::~casBeaconTimer () +{ + delete & this->timer; +} + // // caServerOS::caServerOS() // @@ -43,7 +53,7 @@ caServerOS::caServerOS () // caServerOS::~caServerOS() { - if (this->pBTmr) { + if ( this->pBTmr ) { delete this->pBTmr; } } @@ -51,32 +61,9 @@ caServerOS::~caServerOS() // // casBeaconTimer::expire() // -void casBeaconTimer::expire() +epicsTimerNotify::expireStatus casBeaconTimer::expire() { os.sendBeacon (); -} - -// -// casBeaconTimer::again() -// -bool casBeaconTimer::again() const -{ - return true; -} - -// -// casBeaconTimer::delay() -// -double casBeaconTimer::delay() const -{ - return os.getBeaconPeriod(); -} - -// -// casBeaconTimer::name() -// -const char *casBeaconTimer::name() const -{ - return "casBeaconTimer"; + return expireStatus ( restart, os.getBeaconPeriod() ); } diff --git a/src/cas/generic/st/casDGIntfOS.cc b/src/cas/generic/st/casDGIntfOS.cc index ad4fd5bb9..e1fec5a8e 100644 --- a/src/cas/generic/st/casDGIntfOS.cc +++ b/src/cas/generic/st/casDGIntfOS.cc @@ -66,40 +66,29 @@ private: // // class casDGEvWakeup // -class casDGEvWakeup : public osiTimer { +class casDGEvWakeup : public epicsTimerNotify { public: - - casDGEvWakeup(casDGIntfOS &osIn) : - osiTimer(0.0), os(osIn) {} - + casDGEvWakeup ( casDGIntfOS &osIn ); ~casDGEvWakeup(); - - void expire(); - - void show(unsigned level) const; - - const char *name() const; - + void show ( unsigned level ) const; private: + epicsTimer &timer; casDGIntfOS &os; + expireStatus expire(); }; // // class casDGIOWakeup // -class casDGIOWakeup : public osiTimer { +class casDGIOWakeup : public epicsTimerNotify { public: - casDGIOWakeup (casDGIntfOS &osIn) : - osiTimer (0.0), os(osIn) {} + casDGIOWakeup ( casDGIntfOS &osIn ); ~casDGIOWakeup (); - - void expire(); - - void show(unsigned level) const; - - const char *name() const; + void show ( unsigned level ) const; private: + epicsTimer &timer; casDGIntfOS &os; + expireStatus expire(); }; // @@ -137,6 +126,14 @@ casDGIntfOS::~casDGIntfOS() } } +// +// casDGEvWakeup::casDGEvWakeup() +// +casDGEvWakeup::casDGEvWakeup ( casDGIntfOS &osIn ) : + timer ( fileDescriptorManager.timerQueueRef().createTimer(*this) ), os ( osIn ) +{ + this->timer.start ( 0.0 ); +} // // casDGEvWakeup::~casDGEvWakeup() @@ -144,33 +141,36 @@ casDGIntfOS::~casDGIntfOS() casDGEvWakeup::~casDGEvWakeup() { this->os.pEvWk = NULL; -} - -// -// casDGEvWakeup::name() -// -const char *casDGEvWakeup::name() const -{ - return "casDGEvWakeup"; + delete & this->timer; } // // casDGEvWakeup::show() // -void casDGEvWakeup::show(unsigned level) const +void casDGEvWakeup::show ( unsigned level ) const { printf ( "casDGEvWakeup at %p {\n", static_cast ( this ) ); - this->osiTimer::show(level); + this->timer.show ( level ); printf ("}\n"); } // // casDGEvWakeup::expire() // -void casDGEvWakeup::expire() +epicsTimerNotify::expireStatus casDGEvWakeup::expire() { this->os.casEventSys::process(); + return noRestart; +} + +// +// casDGIOWakeup::casDGIOWakeup() +// +casDGIOWakeup::casDGIOWakeup ( casDGIntfOS &osIn ) : + timer ( fileDescriptorManager.timerQueueRef().createTimer(*this) ), os ( osIn ) +{ + this->timer.start ( 0.0 ); } // @@ -179,6 +179,7 @@ void casDGEvWakeup::expire() casDGIOWakeup::~casDGIOWakeup() { this->os.pIOWk = NULL; + delete & this->timer; } // @@ -188,7 +189,7 @@ casDGIOWakeup::~casDGIOWakeup() // guarantees that we will not call processInput() // recursively // -void casDGIOWakeup::expire() +epicsTimerNotify::expireStatus casDGIOWakeup::expire() { // // in case there is something in the input buffer @@ -200,14 +201,7 @@ void casDGIOWakeup::expire() // be something to read from TCP this works // this->os.processInput (); -} - -// -// casDGIOWakeup::name() -// -const char *casDGIOWakeup::name() const -{ - return "casDGIOWakeup"; + return noRestart; } // @@ -217,8 +211,8 @@ void casDGIOWakeup::show(unsigned level) const { printf ( "casDGIOWakeup at %p {\n", static_cast ( this ) ); - this->osiTimer::show(level); - printf ("}\n"); + this->timer.show ( level ); + printf ( "}\n" ); } // diff --git a/src/cas/generic/st/casDGOS.cc b/src/cas/generic/st/casDGOS.cc index 87d4f9659..ee0a00631 100644 --- a/src/cas/generic/st/casDGOS.cc +++ b/src/cas/generic/st/casDGOS.cc @@ -5,45 +5,6 @@ * $Id$ * * - * $Log$ - * Revision 1.8 1999/09/02 21:50:23 jhill - * o changed UDP to non-blocking IO - * o cleaned up (consolodated) UDP interface class structure - * - * Revision 1.7 1999/08/05 00:07:56 jhill - * osiTimer constructor now requires delay of type double - * - * Revision 1.6 1998/10/23 00:27:14 jhill - * fixed problem where send was not always rearmed if this - * was indirectly necessary in the send callback because - * in this callback the code considered sends to be still armed - * until the send callback completed - * - * Revision 1.5 1998/07/08 15:38:10 jhill - * fixed lost monitors during flow control problem - * - * Revision 1.4 1997/08/05 00:47:19 jhill - * fixed warnings - * - * Revision 1.3 1997/06/30 22:54:33 jhill - * use %p with pointers - * - * Revision 1.2 1997/04/10 19:34:30 jhill - * API changes - * - * Revision 1.1 1996/11/02 01:01:29 jhill - * installed - * - * Revision 1.3 1996/09/16 18:27:50 jhill - * vxWorks port changes - * - * Revision 1.2 1996/08/05 19:29:25 jhill - * os depen code now smaller - * - * Revision 1.1.1.1 1996/06/20 00:28:06 jhill - * ca server installation - * - * */ #if 0 @@ -53,33 +14,33 @@ // #include "server.h" -class casDGEvWakeup : public osiTimer { +class casDGEvWakeup : public epicsTimerNotify { public: - casDGEvWakeup (casDGOS &osIn) : - osiTimer (0.0), os(osIn) {} + casDGEvWakeup (casDGOS &osIn); ~casDGEvWakeup(); - void expire(); void show (unsigned level) const; - - const char *name() const; private: + epicsTimer &timer; casDGOS &os; + expireStatus expire (); }; +// +// casDGEvWakeup::casDGEvWakeup() +// +casDGEvWakeup::asDGEvWakeup ( casDGOS &osIn ) : + timer ( fileDescriptorManager.timerQueRef().createTimer(*this) ), os ( osIn ) +{ + this->timer.start ( 0.0 ); +} + // // casDGEvWakeup::~casDGEvWakeup() // casDGEvWakeup::~casDGEvWakeup() { os.pEvWk = NULL; -} - -// -// casDGEvWakeup::name() -// -const char *casDGEvWakeup::name() const -{ - return "casDGEvWakeup"; + delete & this->timer; } // @@ -87,18 +48,17 @@ const char *casDGEvWakeup::name() const // void casDGEvWakeup::show(unsigned level) const { - this->osiTimer::show(level); - printf("casDGEvWakeup at %p\n", this); + printf ( "casDGEvWakeup at %p\n", this ); + this->timer.show ( level ); } // // casDGEvWakeup::expire() // -void casDGEvWakeup::expire() +epicsTimerNotify::expireStatus casDGEvWakeup::expire() { - casProcCond cond; - cond = this->os.eventSysProcess(); - if (cond != casProcOk) { + casProcCond cond = this->os.eventSysProcess(); + if ( cond != casProcOk ) { // // ok to delete the client here // because casStreamEvWakeup::expire() @@ -113,8 +73,8 @@ void casDGEvWakeup::expire() // must not touch the "this" pointer // from this point on however // - return; } + return noRestart; } // diff --git a/src/cas/generic/st/casOSD.h b/src/cas/generic/st/casOSD.h index ad53e7da2..381cca0aa 100644 --- a/src/cas/generic/st/casOSD.h +++ b/src/cas/generic/st/casOSD.h @@ -10,7 +10,6 @@ #define includeCASOSDH #undef epicsExportSharedSymbols -#include "osiTimer.h" #include "fdManager.h" #define epicsExportSharedSymbols diff --git a/src/cas/generic/st/casStreamOS.cc b/src/cas/generic/st/casStreamOS.cc index 2d7806870..8859294ad 100644 --- a/src/cas/generic/st/casStreamOS.cc +++ b/src/cas/generic/st/casStreamOS.cc @@ -107,38 +107,33 @@ inline casStreamWriteReg::~casStreamWriteReg () // // class casStreamEvWakeup // -class casStreamEvWakeup : public osiTimer { +class casStreamEvWakeup : public epicsTimerNotify { public: - - casStreamEvWakeup(casStreamOS &osIn) : - osiTimer(0.0), os(osIn) {} - - ~casStreamEvWakeup(); - - void expire(); - - void show(unsigned level) const; - - const char *name() const; - + casStreamEvWakeup(casStreamOS &osIn); + ~casStreamEvWakeup (); + void show ( unsigned level ) const; private: + epicsTimer &timer; casStreamOS &os; + expireStatus expire (); }; +// +// casStreamEvWakeup() +// +casStreamEvWakeup::casStreamEvWakeup ( casStreamOS &osIn ) : + timer ( fileDescriptorManager.timerQueueRef().createTimer(*this) ), os(osIn) +{ + this->timer.start ( 0.0 ); +} + // // casStreamEvWakeup::~casStreamEvWakeup() // casStreamEvWakeup::~casStreamEvWakeup() { this->os.pEvWk = NULL; -} - -// -// casStreamEvWakeup::name() -// -const char *casStreamEvWakeup::name() const -{ - return "casStreamEvWakeup"; + delete & this->timer; } // @@ -148,14 +143,14 @@ void casStreamEvWakeup::show(unsigned level) const { printf ( "casStreamEvWakeup at %p {\n", static_cast ( this ) ); - this->osiTimer::show(level); - printf ("}\n"); + this->timer.show ( level ); + printf ( "}\n" ); } // // casStreamEvWakeup::expire() // -void casStreamEvWakeup::expire() +epicsTimerNotify::expireStatus casStreamEvWakeup::expire() { casProcCond cond; cond = this->os.casEventSys::process(); @@ -174,42 +169,40 @@ void casStreamEvWakeup::expire() // must not touch the "this" pointer // from this point on however // - return; } + return noRestart; } // // class casStreamIOWakeup // -class casStreamIOWakeup : public osiTimer { +class casStreamIOWakeup : public epicsTimerNotify { public: - casStreamIOWakeup(casStreamOS &osIn) : - osiTimer (0.0), os(osIn) {} + casStreamIOWakeup(casStreamOS &osIn); ~casStreamIOWakeup(); - - void expire(); - - void show(unsigned level) const; - - const char *name() const; + void show ( unsigned level ) const; private: + epicsTimer &timer; casStreamOS &os; + expireStatus expire (); }; +// +// casStreamIOWakeup::casStreamIOWakeup() +// +casStreamIOWakeup::casStreamIOWakeup ( casStreamOS &osIn ) : + timer ( fileDescriptorManager.timerQueueRef().createTimer(*this) ), os(osIn) +{ + this->timer.start ( 0.0 ); +} + // // casStreamIOWakeup::~casStreamIOWakeup() // casStreamIOWakeup::~casStreamIOWakeup() { this->os.pIOWk = NULL; -} - -// -// casStreamIOWakeup::name() -// -const char *casStreamIOWakeup::name() const -{ - return "casStreamIOWakeup"; + delete & this->timer; } // @@ -219,8 +212,8 @@ void casStreamIOWakeup::show(unsigned level) const { printf ( "casStreamIOWakeup at %p {\n", static_cast ( this ) ); - this->osiTimer::show(level); - printf ("}\n"); + this->timer.show ( level ); + printf ( "}\n" ); } // @@ -246,7 +239,7 @@ inline void casStreamOS::armRecv() // guarantees that we will not call processInput() // recursively // -void casStreamIOWakeup::expire() +epicsTimerNotify::expireStatus casStreamIOWakeup::expire () { // // in case there is something in the input buffer @@ -258,6 +251,7 @@ void casStreamIOWakeup::expire() // be something to read from TCP this works // this->os.processInput(); + return noRestart; } //