From d7b6a509de8b95a7f7bce19c1073308ec06aff34 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 21 Mar 2002 23:39:44 +0000 Subject: [PATCH] epicsAutoMutex has a new name, fixed free lists, and use c++ thread class, and fixed dll symbol exports --- src/db/dbPutNotifyBlocker.cpp | 27 +++++-------------- src/db/dbServiceIO.cpp | 39 ++++++++++----------------- src/db/dbServiceIOReadNotifyCache.cpp | 2 +- src/db/dbSubscriptionIO.cpp | 14 ---------- 4 files changed, 21 insertions(+), 61 deletions(-) diff --git a/src/db/dbPutNotifyBlocker.cpp b/src/db/dbPutNotifyBlocker.cpp index 4bcaac5cf..c5ad62ec6 100644 --- a/src/db/dbPutNotifyBlocker.cpp +++ b/src/db/dbPutNotifyBlocker.cpp @@ -32,30 +32,19 @@ #define epicsExportSharedSymbols #include "dbCAC.h" #include "dbChannelIOIL.h" -#include "dbNotifyBlockerIL.h" - -#if defined ( _MSC_VER ) -# pragma warning ( push ) -# pragma warning ( disable: 4660 ) -#endif - -template class tsFreeList < dbPutNotifyBlocker, 1024, 0 >; - -#if defined ( _MSC_VER ) -# pragma warning ( pop ) -#endif +#include "dbPutNotifyBlocker.h" tsFreeList < dbPutNotifyBlocker, 1024, 0 > dbPutNotifyBlocker::freeList; -epicsMutex dbPutNotifyBlocker::freeListMutex; dbPutNotifyBlocker::dbPutNotifyBlocker ( dbChannelIO &chanIn ) : - chan ( chanIn ), pNotify ( 0 ) + pNotify ( 0 ) { memset ( &this->pn, '\0', sizeof ( this->pn ) ); } dbPutNotifyBlocker::~dbPutNotifyBlocker () { + this->cancel (); } void dbPutNotifyBlocker::destroy () @@ -104,7 +93,7 @@ extern "C" void putNotifyCompletion ( putNotify *ppn ) pBlocker->block.signal (); } -void dbPutNotifyBlocker::initiatePutNotify ( epicsAutoMutex & locker, cacWriteNotify & notify, +void dbPutNotifyBlocker::initiatePutNotify ( epicsGuard < epicsMutex > & locker, cacWriteNotify & notify, struct dbAddr & addr, unsigned type, unsigned long count, const void * pValue ) { int status; @@ -126,7 +115,7 @@ void dbPutNotifyBlocker::initiatePutNotify ( epicsAutoMutex & locker, cacWriteNo beginTimeInit = true; } { - epicsAutoMutexRelease autoRelease ( locker ); + epicsGuardRelease < epicsMutex > autoRelease ( locker ); this->block.wait ( 1.0 ); } } @@ -161,11 +150,7 @@ void dbPutNotifyBlocker::show ( unsigned level ) const printf ( "put notify blocker at %p\n", static_cast ( this ) ); if ( level > 0u ) { - printf ( "\tdbChannelIO at %p\n", - static_cast ( &this->chan ) ); - } - if ( level > 1u ) { - this->block.show ( level - 2u ); + this->block.show ( level - 1u ); } } diff --git a/src/db/dbServiceIO.cpp b/src/db/dbServiceIO.cpp index 0220d5bba..18e1d9904 100644 --- a/src/db/dbServiceIO.cpp +++ b/src/db/dbServiceIO.cpp @@ -25,25 +25,13 @@ #include "caerr.h" // should be eliminated here in the future #include "epicsEvent.h" #include "epicsThread.h" +#include "epicsSingleton.h" #define epicsExportSharedSymbols #include "db_access_routines.h" #include "dbCAC.h" #include "dbChannelIOIL.h" -#include "dbNotifyBlockerIL.h" - -#if defined ( _MSC_VER ) -# pragma warning ( push ) -# pragma warning ( disable: 4660 ) -#endif - -template class chronIntIdResTable < dbBaseIO >; -template class tsSLNode < dbBaseIO >; -template class resTable < dbBaseIO, chronIntId >; - -#if defined ( _MSC_VER ) -# pragma warning ( pop ) -#endif +#include "dbPutNotifyBlocker.h" class dbServiceIOLoadTimeInit { public: @@ -162,7 +150,7 @@ dbEventSubscription dbServiceIO::subscribe ( struct dbAddr & addr, dbChannelIO & int status; { - epicsAutoMutex locker ( this->mutex ); + epicsGuard < epicsMutex > locker ( this->mutex ); if ( ! this->ctx ) { this->ctx = db_init_events (); if ( ! this->ctx ) { @@ -190,7 +178,7 @@ dbEventSubscription dbServiceIO::subscribe ( struct dbAddr & addr, dbChannelIO & es = db_add_event ( this->ctx, &addr, dbSubscriptionEventCallback, (void *) &subscr, mask ); if ( ! es ) { - epicsAutoMutex locker ( this->mutex ); + epicsGuard < epicsMutex > locker ( this->mutex ); chan.dbServicePrivateListOfIO::eventq.remove ( subscr ); this->ioTable.remove ( subscr ); } @@ -198,11 +186,12 @@ dbEventSubscription dbServiceIO::subscribe ( struct dbAddr & addr, dbChannelIO & return es; } -void dbServiceIO::initiatePutNotify ( dbChannelIO &chan, struct dbAddr &addr, - unsigned type, unsigned long count, const void *pValue, - cacWriteNotify ¬ify, cacChannel::ioid *pId ) +void dbServiceIO::initiatePutNotify ( + dbChannelIO & chan, struct dbAddr & addr, + unsigned type, unsigned long count, const void * pValue, + cacWriteNotify & notify, cacChannel::ioid * pId ) { - epicsAutoMutex locker ( this->mutex ); + epicsGuard < epicsMutex > locker ( this->mutex ); if ( ! chan.dbServicePrivateListOfIO::pBlocker ) { chan.dbServicePrivateListOfIO::pBlocker = new dbPutNotifyBlocker ( chan ); if ( ! chan.dbServicePrivateListOfIO::pBlocker ) { @@ -222,7 +211,7 @@ void dbServiceIO::destroyAllIO ( dbChannelIO & chan ) dbSubscriptionIO *pIO; tsDLList < dbSubscriptionIO > tmp; { - epicsAutoMutex locker ( this->mutex ); + epicsGuard < epicsMutex > locker ( this->mutex ); while ( ( pIO = chan.dbServicePrivateListOfIO::eventq.get() ) ) { this->ioTable.remove ( *pIO ); tmp.add ( *pIO ); @@ -247,7 +236,7 @@ void dbServiceIO::destroyAllIO ( dbChannelIO & chan ) void dbServiceIO::ioCancel ( dbChannelIO & chan, const cacChannel::ioid &id ) { - epicsAutoMutex locker ( this->mutex ); + epicsGuard < epicsMutex > locker ( this->mutex ); dbBaseIO *pIO = this->ioTable.remove ( id ); if ( pIO ) { dbSubscriptionIO *pSIO = pIO->isSubscription (); @@ -266,7 +255,7 @@ void dbServiceIO::ioCancel ( dbChannelIO & chan, const cacChannel::ioid &id ) void dbServiceIO::ioShow ( const cacChannel::ioid &id, unsigned level ) const { - epicsAutoMutex locker ( this->mutex ); + epicsGuard < epicsMutex > locker ( this->mutex ); const dbBaseIO *pIO = this->ioTable.lookup ( id ); if ( pIO ) { pIO->show ( level ); @@ -275,7 +264,7 @@ void dbServiceIO::ioShow ( const cacChannel::ioid &id, unsigned level ) const void dbServiceIO::showAllIO ( const dbChannelIO &chan, unsigned level ) const { - epicsAutoMutex locker ( this->mutex ); + epicsGuard < epicsMutex > locker ( this->mutex ); tsDLIterConstBD < dbSubscriptionIO > pItem = chan.dbServicePrivateListOfIO::eventq.firstIter (); while ( pItem.valid () ) { @@ -289,7 +278,7 @@ void dbServiceIO::showAllIO ( const dbChannelIO &chan, unsigned level ) const void dbServiceIO::show ( unsigned level ) const { - epicsAutoMutex locker ( this->mutex ); + epicsGuard < epicsMutex > locker ( this->mutex ); printf ( "dbServiceIO at %p\n", static_cast ( this ) ); if ( level > 0u ) { diff --git a/src/db/dbServiceIOReadNotifyCache.cpp b/src/db/dbServiceIOReadNotifyCache.cpp index 61d016556..93e78e737 100644 --- a/src/db/dbServiceIOReadNotifyCache.cpp +++ b/src/db/dbServiceIOReadNotifyCache.cpp @@ -34,7 +34,7 @@ void dbServiceIOReadNotifyCache::show ( unsigned level ) const void dbServiceIOReadNotifyCache::callReadNotify ( struct dbAddr &addr, unsigned type, unsigned long count, cacReadNotify ¬ify ) { - epicsAutoMutex locker ( this->mutex ); + epicsGuard < epicsMutex > locker ( this->mutex ); unsigned long size = dbr_size_n ( type, count ); diff --git a/src/db/dbSubscriptionIO.cpp b/src/db/dbSubscriptionIO.cpp index a16397c3b..f40903206 100644 --- a/src/db/dbSubscriptionIO.cpp +++ b/src/db/dbSubscriptionIO.cpp @@ -30,19 +30,7 @@ #include "dbChannelIOIL.h" #include "db_access_routines.h" -#if defined ( _MSC_VER ) -# pragma warning ( push ) -# pragma warning ( disable: 4660 ) -#endif - -template class tsFreeList < dbSubscriptionIO >; - -#if defined ( _MSC_VER ) -# pragma warning ( pop ) -#endif - tsFreeList < dbSubscriptionIO > dbSubscriptionIO::freeList; -epicsMutex dbSubscriptionIO::freeListMutex; dbSubscriptionIO::dbSubscriptionIO ( dbServiceIO &serviceIO, dbChannelIO &chanIO, dbAddr &addr, cacStateNotify ¬ifyIn, @@ -91,13 +79,11 @@ void dbSubscriptionIO::channelDeleteException () void * dbSubscriptionIO::operator new ( size_t size ) { - epicsAutoMutex locker ( dbSubscriptionIO::freeListMutex ); return dbSubscriptionIO::freeList.allocate ( size ); } void dbSubscriptionIO::operator delete ( void *pCadaver, size_t size ) { - epicsAutoMutex locker ( dbSubscriptionIO::freeListMutex ); dbSubscriptionIO::freeList.release ( pCadaver, size ); }