22 const double timerQueue :: exceptMsgMinPeriod = 60.0 * 5.0;
24 epicsTimerQueue::~epicsTimerQueue () {}
27 mutex(__FILE__, __LINE__),
32 epicsTime :: getCurrent () - exceptMsgMinPeriod ),
33 cancelPending (
false )
40 while ( ( pTmr = this->timerList.
get () ) ) {
41 pTmr->curState = timer::stateLimbo;
46 printExceptMsg (
const char * pName,
const type_info &
type )
51 epicsTime cur = epicsTime :: getCurrent ();
52 delay = cur - this->exceptMsgTimeStamp;
53 cur.strftime ( date,
sizeof ( date ),
54 "%a %b %d %Y %H:%M:%S.%f" );
55 if ( delay >= exceptMsgMinPeriod ) {
56 this->exceptMsgTimeStamp = cur;
61 strcpy ( date,
"UKN DATE" );
63 if ( delay >= exceptMsgMinPeriod ) {
68 "timerQueue: Unexpected C++ exception \"%s\" " 69 "with type \"%s\" during timer expiration " 82 if ( this->pExpireTmr ) {
87 double delay = pTmr->exp - currentTime;
102 if ( this->timerList.
first () ) {
103 if ( currentTime >= this->timerList.
first ()->exp ) {
104 this->pExpireTmr = this->timerList.
first ();
105 this->timerList.
remove ( *this->pExpireTmr );
106 this->pExpireTmr->curState = timer::stateActive;
109 this->pExpireTmr->
show ( 0u );
113 double delay = this->timerList.
first ()->exp - currentTime;
114 debugPrintf ( (
"no activity process %f to next\n", delay ) );
126 double delay = DBL_MAX;
128 epicsTimerNotify *pTmpNotify = this->pExpireTmr->pNotify;
129 this->pExpireTmr->pNotify = 0;
130 epicsTimerNotify::expireStatus expStat ( epicsTimerNotify::noRestart );
135 debugPrintf ( (
"%5u expired \"%s\" with error %f sec\n",
136 N++,
typeid ( this->pExpireTmr->notify ).name (),
137 currentTime - this->pExpireTmr->exp ) );
139 expStat = pTmpNotify->expire ( currentTime );
141 catch ( std::exception & except ) {
142 printExceptMsg ( except.what (),
typeid ( except ) );
145 printExceptMsg (
"non-standard exception",
typeid (
void ) );
153 if ( this->cancelPending ) {
160 this->cancelPending =
false;
161 this->cancelBlockingEvent.signal ();
164 this->pExpireTmr->curState = timer::stateLimbo;
165 if ( this->pExpireTmr->pNotify ) {
169 this->pExpireTmr->privateStart (
170 *this->pExpireTmr->pNotify, this->pExpireTmr->exp );
172 else if ( expStat.restart() ) {
174 this->pExpireTmr->privateStart (
175 *pTmpNotify, currentTime + expStat.expirationDelay() );
178 this->pExpireTmr = 0;
180 if ( this->timerList.
first () ) {
181 if ( currentTime >= this->timerList.
first ()->exp ) {
182 this->pExpireTmr = this->timerList.
first ();
183 this->timerList.
remove ( *this->pExpireTmr );
184 this->pExpireTmr->curState = timer::stateActive;
186 this->pExpireTmr->
show ( 0u );
190 delay = this->timerList.
first ()->exp - currentTime;
191 this->processThread = 0;
196 this->processThread = 0;
206 return *
new ( this->timerFreeList )
timer ( *
this );
211 return *
new ( this->timerForCFreeList )
epicsTimerForC ( *
this, pCallback, pArg );
217 printf (
"epicsTimerQueue with %u items pending\n", this->timerList.
count () );
220 while ( iter.
valid () ) {
221 iter->
show ( level - 1u );
void show(unsigned int level) const
void show(unsigned int level) const
tsDLIterConst< T > firstIter() const
pvd::StructureConstPtr type
epicsTimer & createTimer()
epicsTimerForC & createTimerForC(epicsTimerCallback pCallback, void *pArg)
void(* epicsTimerCallback)(void *pPrivate)
int errlogPrintf(const char *pFormat,...)
timerQueue(epicsTimerQueueNotify ¬ify)
void date(const char *format)
#define debugPrintf(argsInParen)
double process(const epicsTime ¤tTime)
LIBCOM_API epicsThreadId epicsStdCall epicsThreadGetIdSelf(void)