27 # pragma warning ( push ) 28 # pragma warning ( disable:4660 ) 34 # pragma warning ( pop ) 38 queue ( queueIn ), curState ( stateLimbo ), pNotify ( 0 )
51 queueTmp.timerFreeList.
release (
this );
54 void timer::start ( epicsTimerNotify & notify,
double delaySeconds )
56 this->
start ( notify, epicsTime::getCurrent () + delaySeconds );
59 void timer::start ( epicsTimerNotify & notify,
const epicsTime & expire )
62 this->privateStart ( notify, expire );
65 void timer::privateStart ( epicsTimerNotify & notify,
const epicsTime & expire )
67 this->pNotify = & notify;
68 this->exp = expire - ( this->
queue.notify.quantum () / 2.0 );
70 bool reschedualNeeded =
false;
71 if ( this->curState == stateActive ) {
76 else if ( this->curState == statePending ) {
80 reschedualNeeded =
true;
85 unsigned preemptCount=0u;
97 if ( ! pTmr.
valid () ) {
102 reschedualNeeded =
true;
105 if ( pTmr->exp <= this->exp ) {
118 this->curState = timer::statePending;
120 if ( reschedualNeeded ) {
121 this->
queue.notify.reschedule ();
124 # if defined(DEBUG) && 0 129 debugPrintf ( (
"Start of \"%s\" with delay %f at %p preempting %u\n",
130 typeid ( this->notify ).name (),
131 expire - epicsTime::getCurrent (),
132 this, preemptCount ) );
137 bool reschedual =
false;
138 bool wakeupCancelBlockingThreads =
false;
142 if ( this->curState == statePending ) {
144 this->curState = stateLimbo;
150 else if ( this->curState == stateActive ) {
151 this->
queue.cancelPending =
true;
152 this->curState = timer::stateLimbo;
156 while ( this->
queue.cancelPending &&
157 this->queue.pExpireTmr ==
this ) {
159 this->
queue.cancelBlockingEvent.wait ();
162 wakeupCancelBlockingThreads =
true;
167 this->
queue.notify.reschedule ();
169 if ( wakeupCancelBlockingThreads ) {
170 this->
queue.cancelBlockingEvent.signal ();
180 if ( this->curState == statePending || this->curState == stateActive ) {
181 return expireInfo (
true, this->exp );
183 return expireInfo (
false, epicsTime() );
190 if ( this->curState == statePending || this->curState == stateActive ) {
192 delay = this->exp - epicsTime::getCurrent();
201 const char *pStateName;
202 if ( this->curState == statePending ) {
203 pStateName =
"pending";
205 else if ( this->curState == stateActive ) {
206 pStateName =
"active";
208 else if ( this->curState == stateLimbo ) {
209 pStateName =
"limbo";
212 pStateName =
"corrupt";
214 printf (
"timer, state = %s, delay = %f\n",
216 if ( level >= 1u && this->pNotify ) {
217 this->pNotify->show ( level - 1u );
221 void timer::operator
delete (
void * )
228 errlogPrintf (
"%s:%d this compiler is confused about placement delete - memory was probably leaked",
229 __FILE__, __LINE__ );
232 void epicsTimerForC::operator
delete (
void * )
239 errlogPrintf (
"%s:%d this compiler is confused about placement delete - memory was probably leaked",
240 __FILE__, __LINE__ );
void show(unsigned int level) const
void insertAfter(T &item, T &itemBefore)
void show(unsigned int level) const
epicsPlacementDeleteOperator((void *, tsFreeList< timer, 0x20 > &)) protecte ~timer)()
expireInfo getExpireInfo() const
int errlogPrintf(const char *pFormat,...)
#define debugPrintf(argsInParen)
tsDLIterConst< T > lastIter() const
void start(class epicsTimerNotify &, const epicsTime &)
LIBCOM_API epicsThreadId epicsStdCall epicsThreadGetIdSelf(void)