40 #ifdef ORO_PRAGMA_INTERFACE 41 #pragma implementation 54 using namespace detail;
58 update_period(0.0), mtimeout(false), mstopRequested(false), mwaitpolicy(
ORO_WAIT_ABS)
224 wakeup = wakeup + nsperiod;
233 else if (overruns != 0) {
239 wakeup = now + nsperiod;
253 <<
" got too many periodic overruns in step() (" 254 << overruns <<
" times), stopped Thread !" 256 log(
Critical) <<
" See Thread::setMaxOverrun() for info." 296 log(
Warning) <<
"Failed to stop thread " << this->
getName() <<
": breakLoop() returned false."<<endlog();
304 log(
Error) <<
"Failed to stop thread " << this->
getName() <<
": breakLoop() returned true, but loop() function did not return after "<<
getStopTimeout() <<
" second(s)."<<endlog();
315 log(
Error) <<
"Failed to stop thread " << this->
getName() <<
": step() function did not return after "<<
getStopTimeout() <<
" second(s)."<<endlog();
double update_period
The period at which the Activity steps().
virtual bool stop()
Stop the activity This will stop the activity by removing it from the 'run-queue' of a thread or call...
INTERNAL_QUAL void rtos_task_make_periodic(RTOS_TASK *mytask, NANO_TIME nanosecs)
This function is to inform the RTOS that a thread is switching between periodic or non-periodic execu...
double Seconds
Seconds are stored as a double precision float.
virtual Seconds getPeriod() const
Get the periodicity of this activity in Seconds.
virtual bool isPeriodic() const
Inspect if this activity is periodic.
virtual bool initialize()
A Thread object executes user code in its own thread.
virtual void work(base::RunnableInterface::WorkReason reason)
nsecs getNSecs() const
Get current nsecs of the System clock.
Activity(base::RunnableInterface *r=0, const std::string &name="Activity")
Create a not real-time Activity.
A class for running a certain piece of code in a thread.
bool inloop
Is true when in the loop (isRunning() )
MutexRecursive breaker
Used to implement synchronising breakLoop().
virtual bool setCpuAffinity(unsigned cpu_affinity)
Set cpu affinity for this thread.
static TimeService * Instance()
virtual void step()=0
The method that will be (periodically) executed when this object is run in an Activity.
void setWaitPeriodPolicy(int p)
Set the wait policy of a periodic thread.
virtual bool setPeriod(Seconds period)
Set the periodicity of this activity in Seconds.
RunnableInterface * runner
virtual unsigned getCpuAffinity() const
Get the cpu affinity of this activity.
virtual RTOS_TASK * getTask()
Get the RTOS_TASK pointer.
bool running
Indicates if step() or loop() should be executed.
A thread which is being run.
This file has all the (periodic) thread specific interfaces.
virtual bool isActive() const
Returns whether the thread is active.
Interface to start/stop and query a Activity.
virtual bool execute()
Execute this activity such that it executes a step or loop of the RunnableInterface.
bool wait_until(Mutex &m, nsecs abs_time)
Wait for this condition, but don't wait longer for it than the specified absolute time...
const char * rtos_task_get_name(const RTOS_TASK *task)
Returns the name by which a task is known in the RTOS.
A MutexTimedLock locks a Mutex object on construction and if successful, unlocks it on destruction of...
virtual unsigned getCpuAffinity() const
int maxOverRun
The maximum times a periodic overrun may happen, or -1 if unlimited.
virtual bool timeout()
Requests this Activity to wakeup and call step() + work(Timeout).
virtual bool isRunning() const
Query if the activity is initialized and executing.
bool isSuccessful()
Return if the locking of the Mutex was succesfull.
void terminate()
Exit and destroy the thread.
virtual void finalize()=0
The method that will be called after the last periodical execution of step() ( or non periodical exec...
bool active
When set to 1, the thread will run, when set to 0 the thread will stop ( isActive() ) ...
RTOS_TASK rtos_task
The realtime task structure created by this object.
virtual ~Activity()
Stops and terminates a Activity.
bool setPeriod(Seconds s)
Set the periodicity in Seconds.
virtual void loop()
The method that will be executed once when this class is run in a non periodic Activity.
nsecs Seconds_to_nsecs(const Seconds s)
virtual bool initialize()=0
The method that will be called before the first periodical execution of step() ( or non periodical ex...
virtual bool start()
Start the Thread.
const int LowestPriority
An integer denoting the lowest priority of the selected OS.
virtual bool breakLoop()
This method is called by the framework to break out of the loop() method.
Seconds getStopTimeout() const
Returns the desired timeout for stop(), in seconds.
NANO_TIME period
The period as it is passed to the operating system.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual bool start()
Start the activity.
virtual bool setCpuAffinity(unsigned cpu)
Set the cpu affinity of this activity.
virtual bool trigger()
Trigger that work has to be done.
long long nsecs
nanoseconds as a signed long long.
bool mtimeout
When set to true, a next cycle will be a TimeOut cycle.
virtual os::ThreadInterface * thread()
Returns a pointer to the thread which will run this activity.
virtual bool isPeriodic() const
virtual void work(WorkReason reason)
Identical to step() but gives a reason why the function was called.
virtual const char * getName() const
Read the name of this task.
void broadcast()
Wake all threads that are blocking in wait() or wait_until().
virtual bool isRunning() const
Returns whether the thread is running.
MutexLock is a scope based Monitor, protecting critical sections with a Mutex object through locking ...
virtual bool isActive() const
Query if the activity is started.