This is Unofficial EPICS BASE Doxygen Site
timer Class Reference

#include "timerPrivate.h"

+ Inheritance diagram for timer:
+ Collaboration diagram for timer:

Public Member Functions

void destroy ()
 
void start (class epicsTimerNotify &, const epicsTime &)
 
void start (class epicsTimerNotify &, double delaySeconds)
 
void cancel ()
 
expireInfo getExpireInfo () const
 
void show (unsigned int level) const
 
void * operator new (size_t size, tsFreeList< timer, 0x20 > &)
 
- Public Member Functions inherited from tsDLNode< timer >
 tsDLNode ()
 
 tsDLNode (const tsDLNode< timer > &)
 
const tsDLNode< timer > & operator= (const tsDLNode< timer > &)
 

Public Attributes

epicsPlacementDeleteOperator((void *, tsFreeList< timer, 0x20 > &)) protecte ~timer )()
 
timerQueuequeue
 

Friends

class timerQueue
 

Detailed Description

Definition at line 34 of file timerPrivate.h.

Member Function Documentation

void timer::cancel ( )

Definition at line 135 of file timer.cpp.

136 {
137  bool reschedual = false;
138  bool wakeupCancelBlockingThreads = false;
139  {
140  epicsGuard < epicsMutex > locker ( this->queue.mutex );
141  this->pNotify = 0;
142  if ( this->curState == statePending ) {
143  this->queue.timerList.remove ( *this );
144  this->curState = stateLimbo;
145  if ( this->queue.timerList.first() == this &&
146  this->queue.timerList.count() > 0 ) {
147  reschedual = true;
148  }
149  }
150  else if ( this->curState == stateActive ) {
151  this->queue.cancelPending = true;
152  this->curState = timer::stateLimbo;
153  if ( this->queue.processThread != epicsThreadGetIdSelf() ) {
154  // make certain timer expire() does not run after cancel () returns,
155  // but dont require that lock is applied while calling expire()
156  while ( this->queue.cancelPending &&
157  this->queue.pExpireTmr == this ) {
158  epicsGuardRelease < epicsMutex > autoRelease ( locker );
159  this->queue.cancelBlockingEvent.wait ();
160  }
161  // in case other threads are waiting
162  wakeupCancelBlockingThreads = true;
163  }
164  }
165  }
166  if ( reschedual ) {
167  this->queue.notify.reschedule ();
168  }
169  if ( wakeupCancelBlockingThreads ) {
170  this->queue.cancelBlockingEvent.signal ();
171  }
172 }
unsigned count() const
Definition: tsDLList.h:181
timerQueue & queue
Definition: timerPrivate.h:47
void remove(T &item)
Definition: tsDLList.h:219
T * first(void) const
Definition: tsDLList.h:190
LIBCOM_API epicsThreadId epicsStdCall epicsThreadGetIdSelf(void)
Definition: osdThread.c:810
void timer::destroy ( )

Definition at line 47 of file timer.cpp.

48 {
49  timerQueue & queueTmp = this->queue;
50  this->~timer ();
51  queueTmp.timerFreeList.release ( this );
52 }
epicsPlacementDeleteOperator((void *, tsFreeList< timer, 0x20 > &)) protecte ~timer)()
Definition: timerPrivate.h:46
timerQueue & queue
Definition: timerPrivate.h:47
void release(void *p)
Definition: tsFreeList.h:176
epicsTimer::expireInfo timer::getExpireInfo ( ) const

Definition at line 174 of file timer.cpp.

175 {
176  // taking a lock here guarantees that users will not
177  // see brief intervals when a timer isnt active because
178  // it is is canceled when start is called
179  epicsGuard < epicsMutex > locker ( this->queue.mutex );
180  if ( this->curState == statePending || this->curState == stateActive ) {
181  return expireInfo ( true, this->exp );
182  }
183  return expireInfo ( false, epicsTime() );
184 }
timerQueue & queue
Definition: timerPrivate.h:47
void * timer::operator new ( size_t  size,
tsFreeList< timer, 0x20 > &  freeList 
)
inline

Definition at line 238 of file timerPrivate.h.

240 {
241  return freeList.allocate ( size );
242 }
void * allocate(size_t size)
Definition: tsFreeList.h:126
void timer::show ( unsigned int  level) const

Definition at line 186 of file timer.cpp.

187 {
188  epicsGuard < epicsMutex > locker ( this->queue.mutex );
189  double delay;
190  if ( this->curState == statePending || this->curState == stateActive ) {
191  try {
192  delay = this->exp - epicsTime::getCurrent();
193  }
194  catch ( ... ) {
195  delay = - DBL_MAX;
196  }
197  }
198  else {
199  delay = -DBL_MAX;
200  }
201  const char *pStateName;
202  if ( this->curState == statePending ) {
203  pStateName = "pending";
204  }
205  else if ( this->curState == stateActive ) {
206  pStateName = "active";
207  }
208  else if ( this->curState == stateLimbo ) {
209  pStateName = "limbo";
210  }
211  else {
212  pStateName = "corrupt";
213  }
214  printf ( "timer, state = %s, delay = %f\n",
215  pStateName, delay );
216  if ( level >= 1u && this->pNotify ) {
217  this->pNotify->show ( level - 1u );
218  }
219 }
#define printf
Definition: epicsStdio.h:41
timerQueue & queue
Definition: timerPrivate.h:47
void timer::start ( class epicsTimerNotify &  notify,
const epicsTime &  expire 
)

Definition at line 59 of file timer.cpp.

60 {
61  epicsGuard < epicsMutex > locker ( this->queue.mutex );
62  this->privateStart ( notify, expire );
63 }
timerQueue & queue
Definition: timerPrivate.h:47
void timer::start ( class epicsTimerNotify &  notify,
double  delaySeconds 
)

Definition at line 54 of file timer.cpp.

55 {
56  this->start ( notify, epicsTime::getCurrent () + delaySeconds );
57 }
void start(class epicsTimerNotify &, const epicsTime &)
Definition: timer.cpp:59

Friends And Related Function Documentation

friend class timerQueue
friend

Definition at line 61 of file timerPrivate.h.

Member Data Documentation

timerQueue& timer::queue

Definition at line 47 of file timerPrivate.h.

timer::~timer

Definition at line 46 of file timerPrivate.h.


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