![]() |
Laelaps
2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
|
#include <laeThreadAsync.h>
Public Member Functions | |
| LaeThreadAsync () | |
| Default constructor. | |
| virtual | ~LaeThreadAsync () |
| Destructor. | |
| virtual int | createThread (LaeAsyncJob *pJob, int nPriority=ThreadAsyncPrioDft) |
| Create the thread. More... | |
| virtual int | runThread (const double fHz=ThreadAsyncHzDft) |
| Run the thread. More... | |
| virtual int | terminateThread () |
| Terminate the thread. More... | |
| LaeAsyncJob * | getJob () |
| Get attached job. More... | |
Public Member Functions inherited from laelaps::LaeThread | |
| LaeThread (const std::string &strThreadName) | |
| Default constructor. | |
| virtual | ~LaeThread () |
| Destructor. | |
| virtual int | createThread (int nPriority) |
| Create 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 | |
| static const double | ThreadAsyncPrioDft = 25 |
| default priority | |
| static const double | ThreadAsyncHzDft = 1.0 |
| default run rate | |
| static const char *const | ThreadAsyncNameDft = "Async" |
| default name | |
Static Public Attributes inherited from laelaps::LaeThread | |
| static const int | ThreadPriorityMin = 1 |
| minimum scheduling priority | |
| static const int | ThreadPriorityMax = 99 |
| maximum scheduling priority | |
| static const double | ThreadMinHz = 0.001 |
| minimum thread Hertz More... | |
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 | exec () |
| Execute asynchronous task within scheduled cycle. More... | |
| virtual void | transToExit () |
| Any to Exit state transition function. More... | |
Protected Member Functions inherited from laelaps::LaeThread | |
| void | lock () |
| Lock the I2C bus. More... | |
| void | unlock () |
| Unlock the I2C bus. 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 | |
| LaeAsyncJob * | m_pJob |
| attached asynchronous job - owned by caller | |
Protected Attributes inherited from laelaps::LaeThread | |
| 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 (seconds) | |
| struct timespec | m_tsExecPeriod |
| task execution period (converted) | |
| struct timespec | m_tsJitter |
| allowable scheduling jitter | |
| struct timespec | m_tsSched |
| working scheduler time stamp | |
| struct timespec | m_tsExecLast |
| start of last execution time stamp | |
| struct timespec | m_tsExecThis |
| start of this execution time stamp | |
| int | m_nSlipErrCnt |
| slipped error count leaky bucket | |
Additional Inherited Members | |
Public Types inherited from laelaps::LaeThread | |
| enum | ThreadState { ThreadStateUninit, ThreadStateReady, ThreadStateStart, ThreadStateRunning, ThreadStateExit } |
| Kinematics thread states. More... | |
Static Protected Member Functions inherited from laelaps::LaeThread | |
| static void * | thread (void *pArg) |
| The thread. More... | |
Asynchronous thread class.
Definition at line 200 of file laeThreadAsync.h.
|
virtual |
Create the thread.
The thread remains blocked in the ready state until runThread() is called.
| pJob | Asynchronous job. |
| nPriority | Thread OS scheduling priority. |
Definition at line 136 of file laeThreadAsync.cxx.
References laelaps::LaeAsyncJob::abort(), laelaps::LaeThread::createThread(), laelaps::LaeAsyncJob::getJobName(), laelaps::LAE_ECODE_BAD_OP, laelaps::LAE_OK, m_pJob, laelaps::LaeThread::m_strThreadName, and ThreadAsyncNameDft.
Referenced by laelaps::LaeRobot::runAsyncJob().
|
protectedvirtual |
Execute asynchronous task within scheduled cycle.
This function executes under the lock/unlock mutex.
Reimplemented from laelaps::LaeThread.
Definition at line 204 of file laeThreadAsync.cxx.
References laelaps::LaeAsyncJob::abort(), laelaps::LaeThread::changeState(), laelaps::LaeAsyncJob::isDone(), m_pJob, laelaps::LaeAsyncJob::run(), laelaps::LaeAsyncJob::terminate(), and laelaps::LaeThread::ThreadStateExit.
|
inline |
Get attached job.
Definition at line 269 of file laeThreadAsync.h.
|
virtual |
Run the thread.
| fHZ | Thread run rate (Hertz). |
Reimplemented from laelaps::LaeThread.
Definition at line 158 of file laeThreadAsync.cxx.
References laelaps::LAE_ECODE_BAD_OP, m_pJob, laelaps::LaeThread::m_strThreadName, and laelaps::LaeThread::runThread().
Referenced by laelaps::LaeRobot::runAsyncJob().
|
virtual |
Terminate the thread.
This function does not return until the thread actually terminates.
Reimplemented from laelaps::LaeThread.
Definition at line 169 of file laeThreadAsync.cxx.
References laelaps::LaeAsyncJob::abort(), laelaps::LaeAsyncJob::isDone(), m_pJob, laelaps::LaeThread::m_strThreadName, laelaps::LaeThread::terminateThread(), and ThreadAsyncNameDft.
Referenced by laelaps::LaeRobot::cancelAsyncJob().
|
protectedvirtual |
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.
Reimplemented from laelaps::LaeThread.
Definition at line 240 of file laeThreadAsync.cxx.
References laelaps::LaeAsyncJob::abort(), laelaps::LaeAsyncJob::isDone(), m_pJob, laelaps::LaeThread::m_strThreadName, and ThreadAsyncNameDft.
|
protectedvirtual |
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.
Reimplemented from laelaps::LaeThread.
Definition at line 188 of file laeThreadAsync.cxx.
References laelaps::LaeAsyncJob::getReady(), and m_pJob.
|
protectedvirtual |
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.
Reimplemented from laelaps::LaeThread.
Definition at line 196 of file laeThreadAsync.cxx.
References m_pJob, and laelaps::LaeAsyncJob::start().