34 #include <sys/types.h> 41 #include "rnr/rnrconfig.h" 88 Thread(
const std::string &strThreadName);
145 virtual void setHz(
const double fHz);
205 pthread_mutex_lock(&m_mutexSync);
219 pthread_mutex_unlock(&m_mutexSync);
228 void setPriority(
int nPriority, pthread_attr_t &attr);
251 void timedWait(
const struct timespec &tsTimeout);
336 static void *
thread(
void *pArg);
342 #endif // _RNR_THREAD_H int m_nPriority
thread OS scheduling priority
thread created and blocked, ready to start
std::string m_strThreadName
thread identifying name
static const double ThreadMinHz
minimum Hertz rate
double m_fHz
thread cycle run rate (Hertz)
void lock()
Lock the I2C bus.
virtual void transToExit()
Any to Exit state transition function.
static const int ThreadPriorityDft
default thread attributes
ThreadState
Kinematics thread states.
Time functions and class interfaces.
double m_fTExec
task execution cycle period (sec)
virtual int runThread(const double fHz)
Run the thread.
double getThreadHz() const
Get thread run full cycle rate.
virtual void readyBlock()
Block indefinitely while in the ready state.
chronos::Time m_tExecLastTimeStamp
start of last execution time stamp
void setPriority(int nPriority, pthread_attr_t &attr)
Set real-time priority attributes of of the thread to be created.
int getThreadPriority() const
Get thread system scheduling priority.
chronos::Time m_tExecPeriod
task execution period (converted)
Thread(const std::string &strThreadName)
Default constructor.
pthread_t m_thread
pthread identifier
virtual void setHz(const double fHz)
Calculate thread new full cycle run rate.
pthread_mutex_t m_mutexSync
synchonization mutex
virtual void transToReady()
Uninitialized to Ready state transition function.
virtual void exec()
Execute task(s) within scheduled [sub]cycle.
virtual int createThread(int nPriority)
Create the thread.
static void * thread(void *pArg)
The thread.
void unlock()
Unlock the I2C bus.
pthread_cond_t m_condSync
synchonization condition
int m_nSlipErrCnt
slipped error count leaky bucket
void timedWait(const struct timespec &tsTimeout)
Timed wait until state change or time out.
thread created but unitialized
virtual void transToRunning()
Ready to Running state transition function.
std::string getThreadName() const
Get assigned thread name.
chronos::Time m_tExecThisTimeStamp
start of this execution time stamp
virtual int terminateThread()
Terminate the thread.
static const int ThreadPriorityMax
maximum scheduling priority
static const int ThreadPriorityMin
minimum scheduling priority
chronos::Time m_tSched
working scheduler time
virtual ~Thread()
Destructor.
virtual void schedBlock()
Block the thread until the next subcycle task is to be run.
void changeState(ThreadState eNewState)
Change the thread state.
ThreadState m_eState
thread state