This is Unofficial EPICS BASE Doxygen Site
getCallback.cpp
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  *
13  * L O S A L A M O S
14  * Los Alamos National Laboratory
15  * Los Alamos, New Mexico 87545
16  *
17  * Copyright, The Regents of the University of California.
18  *
19  *
20  * Author Jeffrey O. Hill
21  * johill@lanl.gov
22  * 505 665 1831
23  */
24 
25 #include <string>
26 #include <stdexcept>
27 
28 #include "errlog.h"
29 
30 #include "iocinf.h"
31 #include "oldAccess.h"
32 
34  caEventCallBackFunc *pFuncIn, void *pPrivateIn ) :
35  chan ( chanIn ), pFunc ( pFuncIn ), pPrivate ( pPrivateIn )
36 {
37 }
38 
40 {
41 }
42 
45  unsigned type, arrayElementCount count, const void *pData )
46 {
47  struct event_handler_args args;
48  args.usr = this->pPrivate;
49  args.chid = & this->chan;
50  args.type = type;
51  args.count = count;
52  args.status = ECA_NORMAL;
53  args.dbr = pData;
54  caEventCallBackFunc * pFuncTmp = this->pFunc;
55  // fetch client context and destroy prior to releasing
56  // the lock and calling cb in case they destroy channel there
57  this->chan.getClientCtx().destroyGetCallback ( guard, *this );
58  if ( pFuncTmp ) {
59  epicsGuardRelease < epicsMutex > unguard ( guard );
60  pFuncTmp ( args );
61  }
62 }
63 
64 void getCallback::exception (
66  int status, const char * /* pContext */,
67  unsigned type, arrayElementCount count )
68 {
69  if ( status != ECA_CHANDESTROY ) {
70  struct event_handler_args args;
71  args.usr = this->pPrivate;
72  args.chid = & this->chan;
73  args.type = type;
74  args.count = count;
75  args.status = status;
76  args.dbr = 0;
77  caEventCallBackFunc * pFuncTmp = this->pFunc;
78  // fetch client context and destroy prior to releasing
79  // the lock and calling cb in case they destroy channel there
80  this->chan.getClientCtx().destroyGetCallback ( guard, *this );
81  {
82  epicsGuardRelease < epicsMutex > unguard ( guard );
83  ( *pFuncTmp ) ( args );
84  }
85  }
86  else {
87  this->chan.getClientCtx().destroyGetCallback ( guard, *this );
88  }
89 }
90 
91 void getCallback::operator delete ( void * )
92 {
93  // Visual C++ .net appears to require operator delete if
94  // placement operator delete is defined? I smell a ms rat
95  // because if I declare placement new and delete, but
96  // comment out the placement delete definition there are
97  // no undefined symbols.
98  errlogPrintf ( "%s:%d this compiler is confused about placement delete - memory was probably leaked",
99  __FILE__, __LINE__ );
100 }
101 
102 
const void * dbr
Definition: cadef.h:89
void exception epicsGuard< epicsMutex > int const char unsigned arrayElementCount count
Definition: oldAccess.h:210
void caEventCallBackFunc(struct event_handler_args)
Definition: cadef.h:92
void * pPrivate
Definition: oldAccess.h:206
void exception epicsGuard< epicsMutex > int const char unsigned type
Definition: oldAccess.h:210
#define ECA_NORMAL
Definition: caerr.h:77
getCallback(oldChannelNotify &chanIn, caEventCallBackFunc *pFunc, void *pPrivate)
Definition: getCallback.cpp:33
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
unsigned long arrayElementCount
Definition: cacIO.h:57
chanId chid
Definition: cadef.h:86
void exception epicsGuard< epicsMutex > int status
Definition: oldAccess.h:210
#define ECA_CHANDESTROY
Definition: caerr.h:132
void completion(epicsGuard< epicsMutex > &, unsigned type, arrayElementCount count, const void *pData)
Definition: getCallback.cpp:43
epicsPlacementDeleteOperator((void *, tsFreeList< class getCallback, 1024, epicsMutexNOOP > &)) private caEventCallBackFunc pFunc)
Definition: oldAccess.h:201
void * usr
Definition: cadef.h:85