This is Unofficial EPICS BASE Doxygen Site
disconnectGovernorTimer.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 // L O S A L A M O S
12 // Los Alamos National Laboratory
13 // Los Alamos, New Mexico 87545
14 //
15 // Copyright, 1986, The Regents of the University of California.
16 //
17 // Author: Jeff Hill
18 //
19 
20 #define epicsAssertAuthor "Jeff Hill johill@lanl.gov"
21 
23 #include "udpiiu.h"
24 #include "nciu.h"
25 
26 static const double disconnectGovernorPeriod = 10.0; // sec
27 
30  epicsTimerQueue & queueIn,
31  epicsMutex & mutexIn ) :
32  mutex ( mutexIn ), timer ( queueIn.createTimer () ),
33  iiu ( iiuIn )
34 {
35 }
36 
38 {
39  this->timer.destroy ();
40 }
41 
43 {
44  this->timer.start ( *this, disconnectGovernorPeriod );
45 }
46 
48  epicsGuard < epicsMutex > & cbGuard,
50 {
51  {
52  epicsGuardRelease < epicsMutex > unguard ( guard );
53  {
54  epicsGuardRelease < epicsMutex > cbUnguard ( cbGuard );
55  this->timer.cancel ();
56  }
57  }
58  while ( nciu * pChan = this->chanList.get () ) {
59  pChan->channelNode::listMember =
60  channelNode::cs_none;
61  pChan->serviceShutdownNotify ( cbGuard, guard );
62  }
63 }
64 
65 epicsTimerNotify::expireStatus disconnectGovernorTimer::expire (
66  const epicsTime & /* currentTime */ )
67 {
68  epicsGuard < epicsMutex > guard ( this->mutex );
69  while ( nciu * pChan = chanList.get () ) {
70  pChan->channelNode::listMember =
71  channelNode::cs_none;
72  this->iiu.govExpireNotify ( guard, *pChan );
73  }
74  return expireStatus ( restart, disconnectGovernorPeriod );
75 }
76 
77 void disconnectGovernorTimer::show ( unsigned level ) const
78 {
79  epicsGuard < epicsMutex > guard ( this->mutex );
80  ::printf ( "disconnect governor timer: with %u channels pending\n",
81  this->chanList.count () );
82  if ( level > 0u ) {
83  tsDLIterConst < nciu > pChan = this->chanList.firstIter ();
84  while ( pChan.valid () ) {
85  pChan->show ( level - 1u );
86  pChan++;
87  }
88  }
89 }
90 
92  epicsGuard < epicsMutex > & guard, nciu & chan )
93 {
94  guard.assertIdenticalMutex ( this->mutex );
95  this->chanList.add ( chan );
96  chan.channelNode::listMember = channelNode::cs_disconnGov;
97 }
98 
100  epicsGuard < epicsMutex > & guard, nciu & chan )
101 {
102  guard.assertIdenticalMutex ( this->mutex );
103  this->chanList.remove ( chan );
104  chan.channelNode::listMember = channelNode::cs_none;
105 }
106 
108 
void add(T &item)
Definition: tsDLList.h:313
void destroy()
Definition: timer.cpp:47
void uninstallChan(epicsGuard< epicsMutex > &, nciu &)
void show(unsigned level) const
tsDLIterConst< T > firstIter() const
Definition: tsDLList.h:459
#define printf
Definition: epicsStdio.h:41
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
unsigned count() const
Definition: tsDLList.h:181
bool valid() const
Definition: tsDLList.h:506
epicsMutex mutex
Definition: pvAccess.cpp:71
disconnectGovernorTimer(class disconnectGovernorNotify &, epicsTimerQueue &, epicsMutex &)
virtual void govExpireNotify(epicsGuard< epicsMutex > &, nciu &)=0
T * get()
Definition: tsDLList.h:261
void cancel()
Definition: timer.cpp:135
void show(unsigned level) const
Definition: nciu.cpp:472
void remove(T &item)
Definition: tsDLList.h:219
void shutdown(epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
void installChan(epicsGuard< epicsMutex > &, nciu &)
void start(class epicsTimerNotify &, const epicsTime &)
Definition: timer.cpp:59
Definition: nciu.h:127