This is Unofficial EPICS BASE Doxygen Site
tcpSendWatchdog.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  * 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  * Author: Jeff Hill
19  */
20 
21 #define epicsAssertAuthor "Jeff Hill johill@lanl.gov"
22 
23 #include "iocinf.h"
24 #include "cac.h"
25 #include "virtualCircuit.h"
26 
28  epicsMutex & cbMutexIn, cacContextNotify & ctxNotifyIn,
29  epicsMutex & mutexIn, tcpiiu & iiuIn,
30  double periodIn, epicsTimerQueue & queueIn ) :
31  period ( periodIn ), timer ( queueIn.createTimer () ),
32  cbMutex ( cbMutexIn ), ctxNotify ( ctxNotifyIn ),
33  mutex ( mutexIn ), iiu ( iiuIn )
34 {
35 }
36 
38 {
39  this->timer.destroy ();
40 }
41 
42 epicsTimerNotify::expireStatus tcpSendWatchdog::expire (
43  const epicsTime & /* currentTime */ )
44 {
45  {
46  epicsGuard < epicsMutex > guard ( this->mutex );
47  if ( this->iiu.receiveThreadIsBusy ( guard ) ) {
48  return expireStatus ( restart, this->period );
49  }
50  }
51  {
52  callbackManager mgr ( this->ctxNotify, this->cbMutex );
53  epicsGuard < epicsMutex > guard ( this->mutex );
54 # ifdef DEBUG
55  char hostName[128];
56  this->iiu.getHostName ( guard, hostName, sizeof ( hostName ) );
57  debugPrintf ( ( "Request not accepted by CA server %s for %g sec. Disconnecting.\n",
58  hostName, this->period ) );
59 # endif
60  this->iiu.sendTimeoutNotify ( mgr, guard );
61  }
62  return noRestart;
63 }
64 
65 void tcpSendWatchdog::start ( const epicsTime & /* currentTime */ )
66 {
67  this->timer.start ( *this, this->period );
68 }
69 
71 {
72  this->timer.cancel ();
73 }
74 
75 
virtual ~tcpSendWatchdog()
void start(const epicsTime &)
void destroy()
Definition: timer.cpp:47
void sendTimeoutNotify(callbackManager &cbMgr, epicsGuard< epicsMutex > &guard)
Definition: tcpiiu.cpp:878
epicsMutex mutex
Definition: pvAccess.cpp:71
tcpSendWatchdog(epicsMutex &cbMutex, cacContextNotify &ctxNotify, epicsMutex &mutex, tcpiiu &, double periodIn, epicsTimerQueue &queueIn)
void cancel()
Definition: timer.cpp:135
bool receiveThreadIsBusy(epicsGuard< epicsMutex > &)
#define debugPrintf(argsInParen)
Definition: iocinf.h:30
unsigned getHostName(epicsGuard< epicsMutex > &, char *pBuf, unsigned bufLength) const
Definition: tcpiiu.cpp:1791
void start(class epicsTimerNotify &, const epicsTime &)
Definition: timer.cpp:59