many structural improvements

This commit is contained in:
Jeff Hill
2002-04-25 18:35:40 +00:00
parent 2eb3ecf01c
commit 87bc5a7243
2 changed files with 25 additions and 37 deletions

View File

@@ -28,21 +28,10 @@
#include "cac.h"
#include "osiWireFormat.h"
#include "udpiiu.h"
#include "virtualCircuit.h"
#include "cadef.h"
#include "db_access.h" // for INVALID_DB_REQ
#ifdef _MSC_VER
# pragma warning ( push )
# pragma warning ( disable:4660 )
#endif
template class tsFreeList < class nciu, 1024 >;
template class epicsSingleton < tsFreeList < class nciu, 1024 > >;
#ifdef _MSC_VER
# pragma warning ( pop )
#endif
epicsSingleton < tsFreeList < class nciu, 1024 > > nciu::pFreeList;
nciu::nciu ( cac & cacIn, netiiu & iiuIn, cacChannelNotify & chanIn,
@@ -94,6 +83,11 @@ nciu::~nciu ()
delete [] this->pNameStr;
}
void nciu::initiateConnect ()
{
this->cacCtx.initiateConnect ( *this );
}
void nciu::connect ( unsigned nativeType,
unsigned nativeCount, unsigned sidIn, bool v41Ok )
{
@@ -156,7 +150,8 @@ void nciu::disconnect ( netiiu & newiiu )
/*
* nciu::searchMsg ()
*/
bool nciu::searchMsg ( unsigned short retrySeqNumber, unsigned &retryNoForThisChannel )
bool nciu::searchMsg ( udpiiu & iiu, unsigned short retrySeqNumber,
unsigned &retryNoForThisChannel )
{
caHdr msg;
bool success;
@@ -167,7 +162,7 @@ bool nciu::searchMsg ( unsigned short retrySeqNumber, unsigned &retryNoForThisCh
msg.m_count = epicsHTON16 ( CA_MINOR_PROTOCOL_REVISION );
msg.m_cid = this->getId ();
success = this->piiu->pushDatagramMsg ( msg,
success = iiu.pushDatagramMsg ( msg,
this->pNameStr, this->nameLength );
if ( success ) {
//
@@ -195,9 +190,9 @@ unsigned nciu::nameLen () const
return this->nameLength;
}
void nciu::createChannelRequest ()
void nciu::createChannelRequest ( tcpiiu & iiu )
{
this->piiu->createChannelRequest ( *this );
iiu.createChannelRequest ( *this );
this->f_claimSent = true;
}
@@ -324,34 +319,28 @@ void nciu::ioShow ( const ioid &idIn, unsigned level ) const
this->cacCtx.ioShow ( idIn, level );
}
void nciu::initiateConnect ()
{
this->notifyStateChangeFirstConnectInCountOfOutstandingIO ();
this->cacCtx.installNetworkChannel ( *this, this->piiu );
}
void nciu::hostName ( char *pBuf, unsigned bufLength ) const
{
epicsGuard < epicsMutex > locker ( this->cacCtx.mutexRef() );
epicsGuard < cacMutex > locker ( this->cacCtx.mutexRef() );
this->piiu->hostName ( pBuf, bufLength );
}
// deprecated - please do not use, this is _not_ thread safe
const char * nciu::pHostName () const
{
epicsGuard < epicsMutex > locker ( this->cacCtx.mutexRef() );
epicsGuard < cacMutex > locker ( this->cacCtx.mutexRef() );
return this->piiu->pHostName (); // ouch !
}
bool nciu::ca_v42_ok () const
{
epicsGuard < epicsMutex > locker ( this->cacCtx.mutexRef() );
epicsGuard < cacMutex > locker ( this->cacCtx.mutexRef() );
return this->piiu->ca_v42_ok ();
}
short nciu::nativeType () const
{
epicsGuard < epicsMutex > locker ( this->cacCtx.mutexRef() );
epicsGuard < cacMutex > locker ( this->cacCtx.mutexRef() );
short type;
if ( this->f_connected ) {
if ( this->typeCode < SHRT_MAX ) {
@@ -369,7 +358,7 @@ short nciu::nativeType () const
arrayElementCount nciu::nativeElementCount () const
{
epicsGuard < epicsMutex > locker ( this->cacCtx.mutexRef() );
epicsGuard < cacMutex > locker ( this->cacCtx.mutexRef() );
arrayElementCount countOut;
if ( this->f_connected ) {
countOut = this->count;
@@ -382,14 +371,14 @@ arrayElementCount nciu::nativeElementCount () const
caAccessRights nciu::accessRights () const
{
epicsGuard < epicsMutex > locker ( this->cacCtx.mutexRef() );
epicsGuard < cacMutex > locker ( this->cacCtx.mutexRef() );
caAccessRights tmp = this->accessRightState;
return tmp;
}
unsigned nciu::searchAttempts () const
{
epicsGuard < epicsMutex > locker ( this->cacCtx.mutexRef() );
epicsGuard < cacMutex > locker ( this->cacCtx.mutexRef() );
return this->retry;
}
@@ -400,7 +389,7 @@ double nciu::beaconPeriod () const
void nciu::notifyStateChangeFirstConnectInCountOfOutstandingIO ()
{
epicsGuard < epicsMutex > locker ( this->cacCtx.mutexRef() );
epicsGuard < cacMutex > locker ( this->cacCtx.mutexRef() );
// test is performed via a callback so that locking is correct
if ( ! this->f_connectTimeOutSeen && ! this->f_previousConn ) {
if ( this->notify ().includeFirstConnectInCountOfOutstandingIO () ) {
@@ -420,7 +409,7 @@ void nciu::notifyStateChangeFirstConnectInCountOfOutstandingIO ()
void nciu::show ( unsigned level ) const
{
epicsGuard < epicsMutex > locker ( this->cacCtx.mutexRef() );
epicsGuard < cacMutex > locker ( this->cacCtx.mutexRef() );
if ( this->f_connected ) {
char hostNameTmp [256];
this->hostName ( hostNameTmp, sizeof ( hostNameTmp ) );

View File

@@ -59,15 +59,16 @@ class nciu : public cacChannel, public tsDLNode < nciu >,
public:
nciu ( cac &, netiiu &, cacChannelNotify &,
const char *pNameIn, cacChannel::priLev );
~nciu (); // force pool allocation
void connect ( unsigned nativeType,
unsigned nativeCount, unsigned sid, bool v41Ok );
void connect ();
void connectStateNotify () const;
void accessRightsNotify () const;
void disconnect ( netiiu &newiiu );
bool searchMsg ( unsigned short retrySeqNumber,
unsigned &retryNoForThisChannel );
void createChannelRequest ();
bool searchMsg ( class udpiiu & iiu, unsigned short retrySeqNumber,
unsigned & retryNoForThisChannel );
void createChannelRequest ( class tcpiiu & iiu );
bool identifierEquivelence ( unsigned idToMatch );
void * operator new ( size_t size );
void operator delete ( void *pCadaver, size_t size );
@@ -92,8 +93,7 @@ public:
bool previouslyConnected () const;
void writeException ( int status, const char *pContext, unsigned type, arrayElementCount count );
cacChannel::priLev getPriority () const;
protected:
~nciu (); // force pool allocation
void notifyStateChangeFirstConnectInCountOfOutstandingIO ();
private:
caAccessRights accessRightState;
cac & cacCtx;
@@ -128,7 +128,6 @@ private:
double beaconPeriod () const;
bool ca_v42_ok () const;
void hostName ( char *pBuf, unsigned bufLength ) const;
void notifyStateChangeFirstConnectInCountOfOutstandingIO ();
static void stringVerify ( const char *pStr, const unsigned count );
static epicsSingleton < tsFreeList < class nciu, 1024 > > pFreeList;
nciu ( const nciu & );