41 #include "../Activity.hpp" 42 #include "../Logger.hpp" 43 #include "../os/fosi.h" 53 return this->getThread()->getPeriod() == 0;
74 wake_up_time = std::numeric_limits<Time>::max();
75 for (TimerIds::iterator it = mtimers.begin(); it != mtimers.end(); ++it) {
76 if ( it->expires != 0 && it->expires < wake_up_time ) {
77 wake_up_time = it->expires;
78 next_timer_id = it - mtimers.begin();
83 if ( wake_up_time == std::numeric_limits<Time>::max() )
84 ret = mcond.wait( mmutex );
86 ret = mcond.wait_until( mmutex, wake_up_time );
98 if ( next_timer_id <
int(mtimers.size()) ) {
100 TimerIds::iterator tim = mtimers.begin() + next_timer_id;
103 tim->expires += tim->period;
114 mtimers[next_timer_id].expired.broadcast();
121 timeout( next_timer_id );
131 for (
TimerId i = 0; i < (int) mtimers.size(); ++i) {
138 : mThread(0), mdo_quit(false)
141 if (scheduler != -1) {
166 if ( timer_id < 0 || timer_id >=
int(
mtimers.size()) || period < 0.0)
176 mtimers[timer_id].expires = due_time;
185 if ( timer_id < 0 || timer_id >=
int(
mtimers.size()) || wait_time < 0.0)
196 mtimers[timer_id].expires = due_time;
206 if (timer_id < 0 || timer_id >=
int(
mtimers.size()) )
211 return mtimers[timer_id].expires != 0;
217 if (timer_id < 0 || timer_id >=
int(
mtimers.size()) )
233 if (timer_id < 0 || timer_id >=
int(
mtimers.size()) )
240 mtimers[timer_id].expired.broadcast();
247 if (timer_id < 0 || timer_id >=
int(
mtimers.size()) )
252 if (
mtimers[timer_id].expires == 0)
return false;
260 if (timer_id < 0 || timer_id >=
int(
mtimers.size()) )
265 if (
mtimers[timer_id].expires == 0)
return false;
267 return mtimers[timer_id].expired.wait_until(
mmutex, abs_time);
bool isArmed(TimerId timer_id) const
Seconds nsecs_to_Seconds(const nsecs ns)
NANO_TIME rtos_get_time_ns(void)
base::ActivityInterface * mThread
bool killTimer(TimerId timer_id)
bool waitForUntil(RTT::os::Timer::TimerId id, nsecs abs_time)
Timer(TimerId max_timers, int scheduler=-1, int priority=0, const std::string &name=std::string("Timer"))
bool waitFor(RTT::os::Timer::TimerId id)
An Activity executes a RunnableInterface object in a (periodic) thread.
bool arm(TimerId timer_id, Seconds wait_time)
bool startTimer(TimerId timer_id, Seconds period)
void setMaxTimers(TimerId max)
nsecs Seconds_to_nsecs(const Seconds s)
virtual void timeout(TimerId timer_id)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
TimeService::Seconds timeRemaining(TimerId timer_id) const
static Logger::LogFunction endlog()
MutexLock is a scope based Monitor, protecting critical sections with a Mutex object through locking ...