This is Unofficial EPICS BASE Doxygen Site
syncGroup.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 /*
10  *
11  *
12  * L O S A L A M O S
13  * Los Alamos National Laboratory
14  * Los Alamos, New Mexico 87545
15  *
16  * Copyright, 1986, The Regents of the University of California.
17  *
18  *
19  * Author Jeffrey O. Hill
20  * johill@lanl.gov
21  * 505 665 1831
22  */
23 
24 #ifndef INC_syncGroup_H
25 #define INC_syncGroup_H
26 
27 #include "tsDLList.h"
28 #include "tsFreeList.h"
29 #include "resourceLib.h"
30 #include "epicsEvent.h"
31 #include "compilerDependencies.h"
32 
33 #include "libCaAPI.h"
34 #include "cadef.h"
35 #include "cacIO.h"
36 
37 static const unsigned CASG_MAGIC = 0xFAB4CAFE;
38 
39 class syncGroupNotify : public tsDLNode < syncGroupNotify > {
40 public:
41  syncGroupNotify ();
42  virtual void destroy (
43  CallbackGuard & cbGuard,
44  epicsGuard < epicsMutex > & guard ) = 0;
45  virtual bool ioPending (
46  epicsGuard < epicsMutex > & guard ) = 0;
47  virtual void cancel (
48  CallbackGuard & cbGuard,
49  epicsGuard < epicsMutex > & mutualExclusionGuard ) = 0;
50  virtual void show (
52  unsigned level ) const = 0;
53 protected:
54  virtual ~syncGroupNotify ();
55  syncGroupNotify ( const syncGroupNotify & );
57 };
58 
59 struct CASG;
60 
62 public:
63  typedef void ( CASG :: * PRecycleFunc )
65  static syncGroupReadNotify * factory (
67  CASG &, PRecycleFunc, chid, void *pValueIn );
68  void destroy (
69  CallbackGuard & cbGuard,
70  epicsGuard < epicsMutex > & guard );
71  bool ioPending (
72  epicsGuard < epicsMutex > & guard );
74  unsigned type, arrayElementCount count );
75  void cancel (
76  CallbackGuard & cbGuard,
77  epicsGuard < epicsMutex > & guard );
78  void show ( epicsGuard < epicsMutex > &, unsigned level ) const;
79 protected:
80  syncGroupReadNotify ( CASG & sgIn, PRecycleFunc, chid, void * pValueIn );
81  virtual ~syncGroupReadNotify ();
82 private:
83  chid chan;
84  PRecycleFunc pRecycleFunc;
85  CASG & sg;
86  void * pValue;
87  const unsigned magic;
89  bool idIsValid;
90  bool ioComplete;
91  void operator delete ( void * );
92  void * operator new ( size_t,
94  epicsPlacementDeleteOperator (( void *,
96  void completion (
97  epicsGuard < epicsMutex > &, unsigned type,
98  arrayElementCount count, const void * pData );
99  void exception (
100  epicsGuard < epicsMutex > &, int status,
101  const char * pContext, unsigned type, arrayElementCount count );
103  syncGroupReadNotify & operator = ( const syncGroupReadNotify & );
104 };
105 
107 public:
108  typedef void ( CASG :: * PRecycleFunc )
110  static syncGroupWriteNotify * factory (
112  CASG &, PRecycleFunc, chid );
113  void destroy (
114  CallbackGuard & cbGuard,
115  epicsGuard < epicsMutex > & guard );
116  bool ioPending (
117  epicsGuard < epicsMutex > & guard );
118  void begin ( epicsGuard < epicsMutex > &, unsigned type,
119  arrayElementCount count, const void * pValueIn );
120  void cancel (
121  CallbackGuard & cbGuard,
122  epicsGuard < epicsMutex > & guard );
123  void show ( epicsGuard < epicsMutex > &, unsigned level ) const;
124 protected:
125  syncGroupWriteNotify ( struct CASG &, PRecycleFunc, chid );
126  virtual ~syncGroupWriteNotify (); // allocate only from pool
127 private:
128  chid chan;
129  PRecycleFunc pRecycleFunc;
130  CASG & sg;
131  const unsigned magic;
132  cacChannel::ioid id;
133  bool idIsValid;
134  bool ioComplete;
135  void operator delete ( void * );
136  void * operator new ( size_t,
138  epicsPlacementDeleteOperator (( void *,
140  void completion ( epicsGuard < epicsMutex > & );
141  void exception (
142  epicsGuard < epicsMutex > &, int status, const char *pContext,
143  unsigned type, arrayElementCount count );
145  syncGroupWriteNotify & operator = ( const syncGroupWriteNotify & );
146 };
147 
148 struct ca_client_context;
149 
150 template < class T > class sgAutoPtr;
151 
152 struct CASG : public chronIntIdRes < CASG > {
153 public:
154  CASG ( epicsGuard < epicsMutex > &, ca_client_context & cacIn );
155  void destructor (
156  CallbackGuard &,
157  epicsGuard < epicsMutex > & guard );
158  bool ioComplete (
159  CallbackGuard &,
160  epicsGuard < epicsMutex > & guard );
161  bool verify ( epicsGuard < epicsMutex > & ) const;
162  int block ( epicsGuard < epicsMutex > * pcbGuard,
163  epicsGuard < epicsMutex > & guard, double timeout );
164  void reset ( CallbackGuard &, epicsGuard < epicsMutex > & );
165  void show ( epicsGuard < epicsMutex > &, unsigned level ) const;
166  void show ( unsigned level ) const;
167  void get ( epicsGuard < epicsMutex > &, chid pChan,
168  unsigned type, arrayElementCount count, void * pValue );
169  void put ( epicsGuard < epicsMutex > &, chid pChan,
170  unsigned type, arrayElementCount count, const void * pValue );
171  void completionNotify (
173  int printFormated ( const char * pFormat, ... );
174  void exception (
175  epicsGuard < epicsMutex > &, int status, const char * pContext,
176  const char * pFileName, unsigned lineNo );
177  void exception (
178  epicsGuard < epicsMutex > &, int status, const char * pContext,
179  const char * pFileName, unsigned lineNo, oldChannelNotify & chan,
180  unsigned type, arrayElementCount count, unsigned op );
181  void * operator new ( size_t size,
183  epicsPlacementDeleteOperator (( void *,
185 
186 private:
187  tsDLList < syncGroupNotify > ioPendingList;
188  tsDLList < syncGroupNotify > ioCompletedList;
190  ca_client_context & client;
191  unsigned magic;
192  tsFreeList < class syncGroupReadNotify, 128, epicsMutexNOOP > freeListReadOP;
193  tsFreeList < class syncGroupWriteNotify, 128, epicsMutexNOOP > freeListWriteOP;
194 
195  void destroyPendingIO (
196  CallbackGuard & cbGuard,
197  epicsGuard < epicsMutex > & guard );
198  void destroyCompletedIO (
199  CallbackGuard & cbGuard,
200  epicsGuard < epicsMutex > & guard );
201  void recycleReadNotifyIO ( epicsGuard < epicsMutex > &,
202  syncGroupReadNotify & );
203  void recycleWriteNotifyIO ( epicsGuard < epicsMutex > &,
204  syncGroupWriteNotify & );
205 
206  CASG ( const CASG & );
207  CASG & operator = ( const CASG & );
208 
209  void operator delete ( void * );
210 
211  ~CASG ();
212 
213  friend class sgAutoPtr < syncGroupWriteNotify >;
214  friend class sgAutoPtr < syncGroupReadNotify >;
215 };
216 
218 public:
219  boolFlagManager ( bool & flag );
220  ~boolFlagManager ();
221  void release ();
222 private:
223  bool * pBool;
224 };
225 
226 inline boolFlagManager::boolFlagManager ( bool & flagIn ) :
227  pBool ( & flagIn )
228 {
229  *this->pBool = true;
230 }
231 
233 {
234  if ( this->pBool ) {
235  *this->pBool = false;
236  }
237 }
238 
240 {
241  this->pBool = 0;
242 }
243 
244 inline void * CASG::operator new ( size_t size,
246 {
247  return freeList.allocate ( size );
248 }
249 
250 #if defined ( CXX_PLACEMENT_DELETE )
251 inline void CASG::operator delete ( void * pCadaver,
253 {
254  freeList.release ( pCadaver );
255 }
256 #endif
257 
259  epicsGuard < epicsMutex > & /* guard */ )
260 {
261  return ! this->ioComplete;
262 }
263 
265  epicsGuard < epicsMutex > & /* guard */ )
266 {
267  return ! this->ioComplete;
268 }
269 
270 #endif // ifdef INC_syncGroup_H
double timeout
Definition: pvutils.cpp:25
virtual void cancel(CallbackGuard &cbGuard, epicsGuard< epicsMutex > &mutualExclusionGuard)=0
std::tr1::shared_ptr< detail::SharedPut > put
virtual bool ioPending(epicsGuard< epicsMutex > &guard)=0
pvd::Status status
#define verify(exp)
Definition: acctst.c:65
pvd::StructureConstPtr type
epicsTime begin
Definition: caConnTest.cpp:22
virtual void show(epicsGuard< epicsMutex > &, unsigned level) const =0
void release()
Definition: syncGroup.h:239
unsigned ioid
Definition: cacIO.h:173
Definition: server.h:76
bool ioPending(epicsGuard< epicsMutex > &guard)
Definition: syncGroup.h:264
virtual ~syncGroupNotify()
syncGroupNotify & operator=(const syncGroupNotify &)
boolFlagManager(bool &flag)
Definition: syncGroup.h:226
bool ioPending(epicsGuard< epicsMutex > &guard)
Definition: syncGroup.h:258
APIs for the epicsEvent binary semaphore.
virtual void destroy(CallbackGuard &cbGuard, epicsGuard< epicsMutex > &guard)=0
unsigned long arrayElementCount
Definition: cacIO.h:57
ChannelPut::shared_pointer op
Definition: pvAccess.cpp:132
Compiler specific declarations.