Support for delayed or periodic callback execution.
More...
#include "timer.h"
Support for delayed or periodic callback execution.
Definition at line 71 of file timer.h.
epics::pvData::Timer::Timer |
( |
std::string |
threadName, |
|
|
ThreadPriority |
priority |
|
) |
| |
Create a new timer queue
- Parameters
-
threadName | name for the timer thread. |
priority | thread priority |
Definition at line 30 of file timer.cpp.
34 ,thread(threadName,priority,
this)
epics::pvData::Timer::~Timer |
( |
| ) |
|
|
virtual |
Definition at line 137 of file timer.cpp.
void close()
Prevent new callbacks from being scheduled, and cancel pending callbacks.
cancel a callback.
- Parameters
-
timerCallback | the timerCallback to cancel. |
- Returns
- true if the timer was queued, and now is cancelled
Definition at line 60 of file timer.cpp.
63 if(!timerCallback->onList)
return false;
65 timerCallback->onList =
false;
68 for(queue_t::iterator it(queue.begin()), end(queue.end()); it != end; ++it)
71 if(cur.get() == timerCallback.get()) {
77 throw std::logic_error(
"Timer::cancel() onList==true, but not found");
std::tr1::shared_ptr< TimerCallback > TimerCallbackPtr
void epics::pvData::Timer::close |
( |
| ) |
|
Prevent new callbacks from being scheduled, and cancel pending callbacks.
Definition at line 141 of file timer.cpp.
154 for(;!temp.empty(); temp.pop_front()) {
156 head->onList =
false;
157 head->timerStopped();
std::tr1::shared_ptr< TimerCallback > TimerCallbackPtr
void epics::pvData::Timer::dump |
( |
std::ostream & |
o | ) |
const |
show the elements in the timer queue.
- Parameters
-
o | The output stream for the output |
Definition at line 197 of file timer.cpp.
201 epicsTime now(epicsTime::getCurrent());
203 for(queue_t::const_iterator it(queue.begin()), end(queue.end()); it!=end; ++it) {
205 o <<
"timeToRun " << (nodeToCall->timeToRun - now)
206 <<
" period " << nodeToCall->period <<
"\n";
std::tr1::shared_ptr< TimerCallback > TimerCallbackPtr
bool epics::pvData::Timer::isScheduled |
( |
TimerCallbackPtr const & |
timerCallback | ) |
const |
Is the callback scheduled to be called?
- Parameters
-
timerCallback | the timerCallback. |
- Returns
- (false,true) if (not, is) scheduled.
Definition at line 80 of file timer.cpp.
83 return timerCallback->onList;
epics::pvData::Timer::POINTER_DEFINITIONS |
( |
Timer |
| ) |
|
void epics::pvData::Timer::scheduleAfterDelay |
( |
TimerCallbackPtr const & |
timerCallback, |
|
|
double |
delay |
|
) |
| |
schedule a callback after a delay.
- Parameters
-
timerCallback | the timerCallback instance. |
delay | number of seconds before calling callback. |
Definition at line 161 of file timer.cpp.
void schedulePeriodic(TimerCallbackPtr const &timerCallback, double delay, double period)
void epics::pvData::Timer::schedulePeriodic |
( |
TimerCallbackPtr const & |
timerCallback, |
|
|
double |
delay, |
|
|
double |
period |
|
) |
| |
schedule a periodic callback.`
- Parameters
-
timerCallback | the timerCallback instance. |
delay | number of seconds before first callback. |
period | time in seconds between each callback. |
Definition at line 168 of file timer.cpp.
173 epicsTime now(epicsTime::getCurrent());
178 if(timerCallback->onList) {
179 throw std::logic_error(
string(
"already queued"));
184 timerCallback->timerStopped();
188 timerCallback->timeToRun = now + delay;
189 timerCallback->period = period;
191 addElement(timerCallback);
192 wakeup = waiting && queue.front()==timerCallback;
The documentation for this class was generated from the following files: