This is Unofficial EPICS BASE Doxygen Site
CASG Struct Reference

#include "syncGroup.h"

+ Inheritance diagram for CASG:
+ Collaboration diagram for CASG:

Public Member Functions

 CASG (epicsGuard< epicsMutex > &, ca_client_context &cacIn)
 
void destructor (CallbackGuard &, epicsGuard< epicsMutex > &guard)
 
bool ioComplete (CallbackGuard &, epicsGuard< epicsMutex > &guard)
 
bool verify (epicsGuard< epicsMutex > &) const
 
int block (epicsGuard< epicsMutex > *pcbGuard, epicsGuard< epicsMutex > &guard, double timeout)
 
void reset (CallbackGuard &, epicsGuard< epicsMutex > &)
 
void show (epicsGuard< epicsMutex > &, unsigned level) const
 
void show (unsigned level) const
 
void get (epicsGuard< epicsMutex > &, chid pChan, unsigned type, arrayElementCount count, void *pValue)
 
void put (epicsGuard< epicsMutex > &, chid pChan, unsigned type, arrayElementCount count, const void *pValue)
 
void completionNotify (epicsGuard< epicsMutex > &, syncGroupNotify &)
 
int printFormated (const char *pFormat,...)
 
void * operator new (size_t size, tsFreeList< struct CASG, 128, epicsMutexNOOP > &)
 
void destroyPendingIO (CallbackGuard &cbGuard, epicsGuard< epicsMutex > &guard)
 
void destroyCompletedIO (CallbackGuard &cbGuard, epicsGuard< epicsMutex > &guard)
 
void recycleReadNotifyIO (epicsGuard< epicsMutex > &, syncGroupReadNotify &)
 
void recycleWriteNotifyIO (epicsGuard< epicsMutex > &, syncGroupWriteNotify &)
 
 CASG (const CASG &)
 
CASGoperator= (const CASG &)
 
void operator delete (void *)
 
 ~CASG ()
 
- Public Member Functions inherited from chronIntIdRes< CASG >
 chronIntIdRes ()
 
- Public Member Functions inherited from chronIntId
 chronIntId (const unsigned &idIn)
 
- Public Member Functions inherited from intId< unsigned, 8u, sizeof(unsigned)*CHAR_BIT >
 intId (const unsigned &idIn)
 
bool operator== (const intId &idIn) const
 
resTableIndex hash () const
 
const unsigned getId () const
 
- Public Member Functions inherited from tsSLNode< CASG >
 tsSLNode ()
 
tsSLNode< CASG > & operator= (const tsSLNode< CASG > &)
 

Public Attributes

void exception epicsGuard< epicsMutex > int status
 
void exception epicsGuard< epicsMutex > int const char * pContext
 
void exception epicsGuard< epicsMutex > int const char const char * pFileName
 
void exception epicsGuard< epicsMutex > int const char const char unsigned lineNo
 
void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotifychan
 
void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotify unsigned type
 
void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotify unsigned arrayElementCount count
 
void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotify unsigned arrayElementCount unsigned op
 
epicsPlacementDeleteOperator((void *, tsFreeList< struct CASG, 128, epicsMutexNOOP > &)) private tsDLList< syncGroupNotify ioCompletedList )
 
epicsEvent sem
 
ca_client_contextclient
 
unsigned magic
 
tsFreeList< class syncGroupReadNotify, 128, epicsMutexNOOPfreeListReadOP
 
tsFreeList< class syncGroupWriteNotify, 128, epicsMutexNOOPfreeListWriteOP
 

Friends

class sgAutoPtr< syncGroupWriteNotify >
 
class sgAutoPtr< syncGroupReadNotify >
 

Additional Inherited Members

- Protected Attributes inherited from intId< unsigned, 8u, sizeof(unsigned)*CHAR_BIT >
unsigned id
 

Detailed Description

Definition at line 152 of file syncGroup.h.

Constructor & Destructor Documentation

CASG::CASG ( epicsGuard< epicsMutex > &  guard,
ca_client_context cacIn 
)

Definition at line 27 of file CASG.cpp.

27  :
28  client ( cacIn ), magic ( CASG_MAGIC )
29 {
30  client.installCASG ( guard, *this );
31 }
unsigned magic
Definition: syncGroup.h:191
Definition: server.h:76
ca_client_context & client
Definition: syncGroup.h:190
CASG::CASG ( const CASG )
CASG::~CASG ( )

Definition at line 33 of file CASG.cpp.

34 {
35 }

Member Function Documentation

int CASG::block ( epicsGuard< epicsMutex > *  pcbGuard,
epicsGuard< epicsMutex > &  guard,
double  timeout 
)

Definition at line 62 of file CASG.cpp.

66 {
67  epicsTime cur_time;
68  epicsTime beg_time;
69  double delay;
70  double remaining;
71  int status;
72 
73  guard.assertIdenticalMutex ( this->client.mutexRef() );
74 
75  // prevent recursion nightmares by disabling blocking
76  // for IO from within a CA callback.
78  return ECA_EVDISALLOW;
79  }
80 
81  if ( timeout < 0.0 ) {
82  return ECA_TIMEOUT;
83  }
84 
85  cur_time = epicsTime::getCurrent ();
86 
87  this->client.flush ( guard );
88 
89  beg_time = cur_time;
90  delay = 0.0;
91 
92  while ( 1 ) {
93  if ( this->ioPendingList.count() == 0u ) {
94  status = ECA_NORMAL;
95  break;
96  }
97 
98  remaining = timeout - delay;
99  if ( remaining <= CAC_SIGNIFICANT_DELAY ) {
100  /*
101  * Make sure that we take care of
102  * recv backlog at least once
103  */
104  status = ECA_TIMEOUT;
105  break;
106  }
107 
108  if ( pcbGuard ) {
109  epicsGuardRelease < epicsMutex > unguard ( guard );
110  {
111  epicsGuardRelease < epicsMutex > uncbGuard ( *pcbGuard );
112  this->sem.wait ( remaining );
113  }
114  }
115  else {
116  epicsGuardRelease < epicsMutex > unguard ( guard );
117  this->sem.wait ( remaining );
118  }
119 
120  /*
121  * force a time update
122  */
123  cur_time = epicsTime::getCurrent ();
124 
125  delay = cur_time - beg_time;
126  }
127 
128  return status;
129 }
#define ECA_EVDISALLOW
Definition: caerr.h:103
double timeout
Definition: pvutils.cpp:25
epicsEvent sem
Definition: syncGroup.h:189
LIBCOM_API void *epicsStdCall epicsThreadPrivateGet(epicsThreadPrivateId)
Definition: osdThread.c:973
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
epicsThreadPrivateId caClientCallbackThreadId
#define ECA_NORMAL
Definition: caerr.h:77
Definition: server.h:76
#define ECA_TIMEOUT
Definition: caerr.h:87
void exception epicsGuard< epicsMutex > int status
Definition: syncGroup.h:174
#define CAC_SIGNIFICANT_DELAY
Definition: iocinf.h:36
void CASG::completionNotify ( epicsGuard< epicsMutex > &  guard,
syncGroupNotify notify 
)

Definition at line 233 of file CASG.cpp.

235 {
236  guard.assertIdenticalMutex ( this->client.mutexRef() );
237  this->ioPendingList.remove ( notify );
238  this->ioCompletedList.add ( notify );
239  if ( this->ioPendingList.count () == 0u ) {
240  this->sem.signal ();
241  }
242 }
epicsEvent sem
Definition: syncGroup.h:189
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
Definition: server.h:76
epicsPlacementDeleteOperator((void *, tsFreeList< struct CASG, 128, epicsMutexNOOP > &)) private tsDLList< syncGroupNotify ioCompletedList)
Definition: syncGroup.h:183
void CASG::destroyCompletedIO ( CallbackGuard cbGuard,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 141 of file CASG.cpp.

144 {
145  guard.assertIdenticalMutex ( this->client.mutexRef() );
146  syncGroupNotify * pNotify;
147  while ( ( pNotify = this->ioCompletedList.get () ) ) {
148  pNotify->destroy ( cbGuard, guard );
149  }
150 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
Definition: server.h:76
virtual void destroy(CallbackGuard &cbGuard, epicsGuard< epicsMutex > &guard)=0
epicsPlacementDeleteOperator((void *, tsFreeList< struct CASG, 128, epicsMutexNOOP > &)) private tsDLList< syncGroupNotify ioCompletedList)
Definition: syncGroup.h:183
void CASG::destroyPendingIO ( CallbackGuard cbGuard,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 152 of file CASG.cpp.

155 {
156  guard.assertIdenticalMutex ( this->client.mutexRef() );
157  while ( syncGroupNotify * pNotify = this->ioPendingList.first () ) {
158  pNotify->cancel ( cbGuard, guard );
159  // cancel must release the guard while
160  // canceling put callbacks so we
161  // must double check list membership
162  if ( pNotify->ioPending ( guard ) ) {
163  this->ioPendingList.remove ( *pNotify );
164  }
165  else {
166  this->ioCompletedList.remove ( *pNotify );
167  }
168  pNotify->destroy ( cbGuard, guard );
169  }
170 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
Definition: server.h:76
epicsPlacementDeleteOperator((void *, tsFreeList< struct CASG, 128, epicsMutexNOOP > &)) private tsDLList< syncGroupNotify ioCompletedList)
Definition: syncGroup.h:183
void CASG::destructor ( CallbackGuard cbGuard,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 37 of file CASG.cpp.

40 {
41  guard.assertIdenticalMutex ( this->client.mutexRef() );
42 
43  if ( this->verify ( guard ) ) {
44  this->reset ( cbGuard, guard );
45  this->client.uninstallCASG ( guard, *this );
46  this->magic = 0;
47  }
48  else {
49  this->printFormated ( "cac: attempt to destroy invalid sync group ignored\n" );
50  }
51  this->~CASG ();
52 }
void reset(CallbackGuard &, epicsGuard< epicsMutex > &)
Definition: CASG.cpp:131
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
bool verify(epicsGuard< epicsMutex > &) const
Definition: CASG.cpp:54
~CASG()
Definition: CASG.cpp:33
unsigned magic
Definition: syncGroup.h:191
Definition: server.h:76
int printFormated(const char *pFormat,...)
Definition: CASG.cpp:258
void CASG::get ( epicsGuard< epicsMutex > &  guard,
chid  pChan,
unsigned  type,
arrayElementCount  count,
void *  pValue 
)

Definition at line 222 of file CASG.cpp.

224 {
225  guard.assertIdenticalMutex ( this->client.mutexRef() );
226  sgAutoPtr < syncGroupReadNotify > pNotify ( guard, *this );
227  pNotify = syncGroupReadNotify::factory (
228  this->freeListReadOP, *this, & CASG :: recycleReadNotifyIO, pChan, pValue );
229  pNotify->begin ( guard, type, count );
230  pNotify.release ();
231 }
tsFreeList< class syncGroupReadNotify, 128, epicsMutexNOOP > freeListReadOP
Definition: syncGroup.h:192
static syncGroupReadNotify * factory(tsFreeList< class syncGroupReadNotify, 128, epicsMutexNOOP > &, CASG &, PRecycleFunc, chid, void *pValueIn)
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotify unsigned type
Definition: syncGroup.h:177
void recycleReadNotifyIO(epicsGuard< epicsMutex > &, syncGroupReadNotify &)
Definition: CASG.cpp:244
Definition: server.h:76
void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotify unsigned arrayElementCount count
Definition: syncGroup.h:177
bool CASG::ioComplete ( CallbackGuard cbGuard,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 202 of file CASG.cpp.

205 {
206  guard.assertIdenticalMutex ( this->client.mutexRef() );
207  this->destroyCompletedIO ( cbGuard, guard );
208  return this->ioPendingList.count () == 0u;
209 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
Definition: server.h:76
void destroyCompletedIO(CallbackGuard &cbGuard, epicsGuard< epicsMutex > &guard)
Definition: CASG.cpp:141
void CASG::operator delete ( void *  )

Definition at line 298 of file CASG.cpp.

299 {
300  // Visual C++ .net appears to require operator delete if
301  // placement operator delete is defined? I smell a ms rat
302  // because if I declare placement new and delete, but
303  // comment out the placement delete definition there are
304  // no undefined symbols.
305  errlogPrintf ( "%s:%d this compiler is confused about placement delete - memory was probably leaked",
306  __FILE__, __LINE__ );
307 }
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
void * CASG::operator new ( size_t  size,
tsFreeList< struct CASG, 128, epicsMutexNOOP > &  freeList 
)
inline

Definition at line 244 of file syncGroup.h.

246 {
247  return freeList.allocate ( size );
248 }
void * allocate(size_t size)
Definition: tsFreeList.h:126
CASG& CASG::operator= ( const CASG )
int CASG::printFormated ( const char *  pFormat,
  ... 
)

Definition at line 258 of file CASG.cpp.

259 {
260  va_list theArgs;
261  int status;
262 
263  va_start ( theArgs, pformat );
264 
265  status = this->client.varArgsPrintFormated ( pformat, theArgs );
266 
267  va_end ( theArgs );
268 
269  return status;
270 }
Definition: server.h:76
void exception epicsGuard< epicsMutex > int status
Definition: syncGroup.h:174
void CASG::put ( epicsGuard< epicsMutex > &  guard,
chid  pChan,
unsigned  type,
arrayElementCount  count,
const void *  pValue 
)

Definition at line 211 of file CASG.cpp.

213 {
214  guard.assertIdenticalMutex ( this->client.mutexRef() );
215  sgAutoPtr < syncGroupWriteNotify > pNotify ( guard, *this );
217  this->freeListWriteOP, *this, & CASG :: recycleWriteNotifyIO, pChan );
218  pNotify->begin ( guard, type, count, pValue );
219  pNotify.release ();
220 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotify unsigned type
Definition: syncGroup.h:177
Definition: server.h:76
static syncGroupWriteNotify * factory(tsFreeList< class syncGroupWriteNotify, 128, epicsMutexNOOP > &, CASG &, PRecycleFunc, chid)
void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotify unsigned arrayElementCount count
Definition: syncGroup.h:177
void recycleWriteNotifyIO(epicsGuard< epicsMutex > &, syncGroupWriteNotify &)
Definition: CASG.cpp:251
tsFreeList< class syncGroupWriteNotify, 128, epicsMutexNOOP > freeListWriteOP
Definition: syncGroup.h:193
void CASG::recycleReadNotifyIO ( epicsGuard< epicsMutex > &  guard,
syncGroupReadNotify io 
)

Definition at line 244 of file CASG.cpp.

246 {
247  guard.assertIdenticalMutex ( this->client.mutexRef() );
248  this->freeListReadOP.release ( & io );
249 }
tsFreeList< class syncGroupReadNotify, 128, epicsMutexNOOP > freeListReadOP
Definition: syncGroup.h:192
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
Definition: server.h:76
void release(void *p)
Definition: tsFreeList.h:176
void CASG::recycleWriteNotifyIO ( epicsGuard< epicsMutex > &  guard,
syncGroupWriteNotify io 
)

Definition at line 251 of file CASG.cpp.

253 {
254  guard.assertIdenticalMutex ( this->client.mutexRef() );
255  this->freeListWriteOP.release ( & io );
256 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
Definition: server.h:76
tsFreeList< class syncGroupWriteNotify, 128, epicsMutexNOOP > freeListWriteOP
Definition: syncGroup.h:193
void release(void *p)
Definition: tsFreeList.h:176
void CASG::reset ( CallbackGuard cbGuard,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 131 of file CASG.cpp.

134 {
135  guard.assertIdenticalMutex ( this->client.mutexRef() );
136  this->destroyCompletedIO ( cbGuard, guard );
137  this->destroyPendingIO ( cbGuard, guard );
138 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
Definition: server.h:76
void destroyPendingIO(CallbackGuard &cbGuard, epicsGuard< epicsMutex > &guard)
Definition: CASG.cpp:152
void destroyCompletedIO(CallbackGuard &cbGuard, epicsGuard< epicsMutex > &guard)
Definition: CASG.cpp:141
void CASG::show ( epicsGuard< epicsMutex > &  guard,
unsigned  level 
) const

Definition at line 178 of file CASG.cpp.

180 {
181  guard.assertIdenticalMutex ( this->client.mutexRef() );
182  ::printf ( "Sync Group: id=%u, magic=%u, opPend=%u\n",
183  this->getId (), this->magic, this->ioPendingList.count () );
184  if ( level ) {
185  ::printf ( "\tPending" );
186  tsDLIterConst < syncGroupNotify > notifyPending =
187  this->ioPendingList.firstIter ();
188  while ( notifyPending.valid () ) {
189  notifyPending->show ( guard, level - 1u );
190  notifyPending++;
191  }
192  ::printf ( "\tCompleted" );
193  tsDLIterConst < syncGroupNotify > notifyCompleted =
194  this->ioCompletedList.firstIter ();
195  while ( notifyCompleted.valid () ) {
196  notifyCompleted->show ( guard, level - 1u );
197  notifyCompleted++;
198  }
199  }
200 }
#define printf
Definition: epicsStdio.h:41
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
virtual void show(epicsGuard< epicsMutex > &, unsigned level) const =0
bool valid() const
Definition: tsDLList.h:506
unsigned magic
Definition: syncGroup.h:191
Definition: server.h:76
epicsPlacementDeleteOperator((void *, tsFreeList< struct CASG, 128, epicsMutexNOOP > &)) private tsDLList< syncGroupNotify ioCompletedList)
Definition: syncGroup.h:183
void CASG::show ( unsigned  level) const

Definition at line 172 of file CASG.cpp.

173 {
174  epicsGuard < epicsMutex > guard ( this->client.mutexRef () );
175  this->show ( guard, level );
176 }
void show(epicsGuard< epicsMutex > &, unsigned level) const
Definition: CASG.cpp:178
Definition: server.h:76
bool CASG::verify ( epicsGuard< epicsMutex > &  ) const

Definition at line 54 of file CASG.cpp.

55 {
56  return ( this->magic == CASG_MAGIC );
57 }
unsigned magic
Definition: syncGroup.h:191

Friends And Related Function Documentation

friend class sgAutoPtr< syncGroupReadNotify >
friend

Definition at line 214 of file syncGroup.h.

friend class sgAutoPtr< syncGroupWriteNotify >
friend

Definition at line 213 of file syncGroup.h.

Member Data Documentation

void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotify& CASG::chan

Definition at line 177 of file syncGroup.h.

ca_client_context& CASG::client

Definition at line 190 of file syncGroup.h.

void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotify unsigned arrayElementCount CASG::count

Definition at line 177 of file syncGroup.h.

tsFreeList< class syncGroupReadNotify, 128, epicsMutexNOOP > CASG::freeListReadOP

Definition at line 192 of file syncGroup.h.

tsFreeList< class syncGroupWriteNotify, 128, epicsMutexNOOP > CASG::freeListWriteOP

Definition at line 193 of file syncGroup.h.

epicsPlacementDeleteOperator (( void *, tsFreeList < struct CASG, 128, epicsMutexNOOP > & )) private tsDLList< syncGroupNotify CASG::ioCompletedList)

Definition at line 183 of file syncGroup.h.

void exception epicsGuard< epicsMutex > int const char const char unsigned CASG::lineNo

Definition at line 174 of file syncGroup.h.

unsigned CASG::magic

Definition at line 191 of file syncGroup.h.

void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotify unsigned arrayElementCount unsigned CASG::op

Definition at line 177 of file syncGroup.h.

void exception epicsGuard< epicsMutex > int const char * CASG::pContext

Definition at line 174 of file syncGroup.h.

void exception epicsGuard< epicsMutex > int const char const char * CASG::pFileName

Definition at line 174 of file syncGroup.h.

epicsEvent CASG::sem

Definition at line 189 of file syncGroup.h.

void exception epicsGuard< epicsMutex > int CASG::status

Definition at line 174 of file syncGroup.h.

void exception epicsGuard< epicsMutex > int const char const char unsigned oldChannelNotify unsigned CASG::type

Definition at line 177 of file syncGroup.h.


The documentation for this struct was generated from the following files: