epicsAutoMutex has a new name, fixed free lists, and use c++ thread class,

and fixed dll symbol exports
This commit is contained in:
Jeff Hill
2002-03-21 23:39:44 +00:00
parent 20ae242c24
commit d7b6a509de
4 changed files with 21 additions and 61 deletions

View File

@@ -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 <const void *> ( this ) );
if ( level > 0u ) {
printf ( "\tdbChannelIO at %p\n",
static_cast <void *> ( &this->chan ) );
}
if ( level > 1u ) {
this->block.show ( level - 2u );
this->block.show ( level - 1u );
}
}

View File

@@ -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 &notify, 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 <const void *> ( this ) );
if ( level > 0u ) {

View File

@@ -34,7 +34,7 @@ void dbServiceIOReadNotifyCache::show ( unsigned level ) const
void dbServiceIOReadNotifyCache::callReadNotify ( struct dbAddr &addr,
unsigned type, unsigned long count, cacReadNotify &notify )
{
epicsAutoMutex locker ( this->mutex );
epicsGuard < epicsMutex > locker ( this->mutex );
unsigned long size = dbr_size_n ( type, count );

View File

@@ -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 &notifyIn,
@@ -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 );
}