appkit  1.5.1
RoadNarrows Robotics Application Kit
UTThread Class Reference
Inheritance diagram for UTThread:
rnr::Thread

Protected Member Functions

virtual void transToReady ()
 Uninitialized to Ready state transition function. More...
 
virtual void transToRunning ()
 Ready to Running state transition function. More...
 
virtual void transToExit ()
 Any to Exit state transition function. More...
 
virtual void exec ()
 Execute task(s) within scheduled [sub]cycle. More...
 
- Protected Member Functions inherited from rnr::Thread
void lock ()
 Lock the I2C bus. More...
 
void unlock ()
 Unlock the I2C bus. More...
 
void setPriority (int nPriority, pthread_attr_t &attr)
 Set real-time priority attributes of of the thread to be created. More...
 
void changeState (ThreadState eNewState)
 Change the thread state. More...
 
void timedWait (const struct timespec &tsTimeout)
 Timed wait until state change or time out. More...
 
virtual void readyBlock ()
 Block indefinitely while in the ready state. More...
 
virtual void schedBlock ()
 Block the thread until the next subcycle task is to be run. More...
 

Protected Attributes

Random m_rand
 
- Protected Attributes inherited from rnr::Thread
std::string m_strThreadName
 thread identifying name
 
ThreadState m_eState
 thread state
 
pthread_mutex_t m_mutexSync
 synchonization mutex
 
pthread_cond_t m_condSync
 synchonization condition
 
pthread_t m_thread
 pthread identifier
 
int m_nPriority
 thread OS scheduling priority
 
double m_fHz
 thread cycle run rate (Hertz)
 
double m_fTExec
 task execution cycle period (sec)
 
chronos::Time m_tExecPeriod
 task execution period (converted)
 
chronos::Time m_tSched
 working scheduler time
 
chronos::Time m_tExecLastTimeStamp
 start of last execution time stamp
 
chronos::Time m_tExecThisTimeStamp
 start of this execution time stamp
 
int m_nSlipErrCnt
 slipped error count leaky bucket
 

Additional Inherited Members

- Public Types inherited from rnr::Thread
enum  ThreadState {
  ThreadStateUninit,
  ThreadStateReady,
  ThreadStateStart,
  ThreadStateRunning,
  ThreadStateExit
}
 Kinematics thread states. More...
 
- Public Member Functions inherited from rnr::Thread
 Thread (const std::string &strThreadName)
 Default constructor.
 
virtual ~Thread ()
 Destructor.
 
virtual int createThread (int nPriority)
 Create the thread. More...
 
virtual int runThread (const double fHz)
 Run the thread. More...
 
virtual int terminateThread ()
 Terminate the thread. More...
 
virtual void setHz (const double fHz)
 Calculate thread new full cycle run rate. More...
 
std::string getThreadName () const
 Get assigned thread name. More...
 
int getThreadPriority () const
 Get thread system scheduling priority. More...
 
double getThreadHz () const
 Get thread run full cycle rate. More...
 
- Static Public Attributes inherited from rnr::Thread
static const int ThreadPriorityDft = 0
 default thread attributes
 
static const int ThreadPriorityMin = 1
 minimum scheduling priority
 
static const int ThreadPriorityMax = 99
 maximum scheduling priority
 
static const double ThreadMinHz = 0.001
 minimum Hertz rate More...
 
- Static Protected Member Functions inherited from rnr::Thread
static void * thread (void *pArg)
 The thread. More...
 

Detailed Description

Definition at line 121 of file utThread.cxx.

Member Function Documentation

virtual void UTThread::exec ( )
inlineprotectedvirtual

Execute task(s) within scheduled [sub]cycle.

This function is called every cycle in the Running state.

A hook for any derived thread class. A simple debug print execution for the base class.

This function executes under the lock/unlock mutex.

Context:
This thread.

Reimplemented from rnr::Thread.

Definition at line 150 of file utThread.cxx.

References OptsRand, and rnr::Random::uniform().

151  {
152  ulong_t usec;
153  double f;
154 
155  Thread::exec();
156 
157  if( OptsRand )
158  {
159  f = (double)m_rand.uniform(0.0, 2.0);
160  usec = (ulong_t)(f * m_fTExec * 1000000);
161  usleep(usec);
162  }
163  }
static bool_t OptsRand
thread random jitter
Definition: utThread.cxx:65
double m_fTExec
task execution cycle period (sec)
Definition: Thread.h:188
float uniform(float fMin=0.0, float fMax=1.0)
Generates a random float uniformally distrubuted between [fMin, fMax].
Definition: Random.cxx:106
virtual void UTThread::transToExit ( )
inlineprotectedvirtual

Any to Exit state transition function.

This function is called after entering the Exit state but prior to terminating the thread.

A hook for any derived thread class. A no-op for the base class.

This function does not execute under the lock/unlock mutex.

Context:
This thread.

Reimplemented from rnr::Thread.

Definition at line 145 of file utThread.cxx.

146  {
147  printf("UTThread::transToExit, state=%d\n", m_eState);
148  }
ThreadState m_eState
thread state
Definition: Thread.h:180
virtual void UTThread::transToReady ( )
inlineprotectedvirtual

Uninitialized to Ready state transition function.

This function is called after entering the Ready state but prior to being blocked waiting to be run.

A hook for any derived thread class. A no-op for the base class.

This function does not execute under the lock/unlock mutex.

Context:
This thread.

Reimplemented from rnr::Thread.

Definition at line 135 of file utThread.cxx.

136  {
137  printf("UTThread::transToReady, state=%d\n", m_eState);
138  }
ThreadState m_eState
thread state
Definition: Thread.h:180
virtual void UTThread::transToRunning ( )
inlineprotectedvirtual

Ready to Running state transition function.

This function is called after entering the Running state but prior to any run execution.

A hook for any derived thread class. A no-op for the base class.

This function does not execute under the lock/unlock mutex.

Context:
This thread.

Reimplemented from rnr::Thread.

Definition at line 140 of file utThread.cxx.

141  {
142  printf("UTThread::transToRunning, state=%d\n", m_eState);
143  }
ThreadState m_eState
thread state
Definition: Thread.h:180

The documentation for this class was generated from the following file: