eXtended (blocking) thread of the QXK preemptive kernel More...
Public Member Functions | |
| QXThread (QXThreadHandler const handler, std::uint_fast8_t const tickRate=0U) noexcept | |
| Constructor of an extended-thread. | |
| void | init (void const *const e, std::uint_fast8_t const qsId) override |
| Take the top-most initial transition in QActive (delegate to QP::QHsm). | |
| void | init (std::uint_fast8_t const qsId) override |
| Takes the top-most initial transition without the initialization parameter (documented and traced together with the other overload under the code UID QP::QAsm::init()). | |
| void | dispatch (QEvt const *const e, std::uint_fast8_t const qsId) override |
| Dispatch an event to QActive (delegate to QP::QHsm). | |
| void | start (QPrioSpec const prioSpec, QEvtPtr *const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize, void const *const par=nullptr) |
| Start execution of an eXtended thread and register it with the framework. | |
| QTimeEvt const * | getTimeEvt () const & |
| QTimeEvt const * | getTimeEvt () const &&=delete |
| bool | delayCancel () noexcept |
| Cancel the delay. | |
| Public Member Functions inherited from QP::QActive | |
| bool | isIn (QStateHandler const stateHndl) noexcept override |
| Is-in-state query in QActive (delegate to QP::QHsm). | |
| QStateHandler | getStateHandler () const noexcept override |
| Get current state-handler in QActive (delegate to QP::QHsm). | |
| QStateHandler | childState (QStateHandler const parentHandler) noexcept |
| Obtain the current active child state of a given parent in QP::QActive (delegate to QP::QHsm). | |
| void | setAttr (std::uint32_t attr1, void const *attr2=nullptr) |
| Generic setting of additional attributes (defined in some QP ports). | |
| void | start (QPrioSpec const prioSpec, QEvtPtr *const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize, void const *const par=nullptr) |
| Starts execution of an active object and registers the object with the framework. | |
| void | stop () |
| Stops execution of an active object and removes it from the framework's supervision. | |
| void | register_ () noexcept |
| Register this active object to be managed by the framework. | |
| void | unregister_ () noexcept |
| Un-register the active object from the framework. | |
| void | post_ (QEvt const *const e, void const *const sender) noexcept |
| Posts an event e directly to the event queue of the active object using the First-In-First-Out (FIFO) policy. | |
| bool | postx_ (QEvt const *const e, std::uint_fast16_t const margin, void const *const sender) noexcept |
| Posts an event e directly to the event queue of the active object using the First-In-First-Out (FIFO) policy. | |
| void | postLIFO (QEvt const *const e) noexcept |
| Posts an event e directly to the event queue of the active object using the Last-In-First-Out (LIFO) policy. | |
| QEvt const * | get_ () noexcept |
| Get an event from the event queue of an active object. | |
| void | subscribe (QSignal const sig) const noexcept |
| Subscribes for delivery of signal sig to the active object. | |
| void | unsubscribe (QSignal const sig) const noexcept |
| Unsubscribes from the delivery of signal sig to the active object. | |
| void | unsubscribeAll () const noexcept |
| Unsubscribes from the delivery of all signals to the active object. | |
| bool | defer (QEQueue *const eq, QEvt const *const e) const noexcept |
| Defer an event to a given separate event queue. | |
| bool | recall (QEQueue *const eq) noexcept |
| Recall a deferred event from a given event queue. | |
| std::uint16_t | flushDeferred (QEQueue *const eq, std::uint_fast16_t const num=0xFFFFU) const noexcept |
| Flush the specified deferred queue eq. | |
| std::uint8_t | getPrio () const noexcept |
| QACTIVE_THREAD_TYPE const & | getThread () const & |
| QACTIVE_THREAD_TYPE const & | getThread () const &&=delete |
| void | setThread (QACTIVE_THREAD_TYPE const &thr) noexcept |
| QACTIVE_OS_OBJ_TYPE const & | getOsObject () const & |
| QACTIVE_OS_OBJ_TYPE const & | getOsObject () const &&=delete |
| virtual bool | postFromISR (QEvt const *const e, std::uint_fast16_t const margin, void *const par, void const *const sender) noexcept |
| The "FromISR" variant used in the QP port to "FreeRTOS" . | |
| Public Member Functions inherited from QP::QAsm | |
| virtual | ~QAsm ()=default |
| Virtual destructor of the QP::QAsm abstract base class. | |
| QStateHandler | state () const noexcept |
| Obtain the current active state from a state machine (read only). | |
| QMState const * | stateObj () const noexcept |
| Obtain the current state from a MSM (read only). | |
Static Public Member Functions | |
| static bool | delay (QTimeEvtCtr const nTicks) noexcept |
| Delay (block) the current extended thread for a specified # ticks. | |
| static QEvt const * | queueGet (QTimeEvtCtr const nTicks=QXTHREAD_NO_TIMEOUT) noexcept |
| Obtain a message from the private message queue (block if no messages). | |
| Static Public Member Functions inherited from QP::QActive | |
| static std::uint16_t | getQueueUse (std::uint_fast8_t const prio) noexcept |
| Obtain the number of entries in use in the queue. | |
| static std::uint16_t | getQueueFree (std::uint_fast8_t const prio) noexcept |
| Obtain the number of free entries still available in the queue. | |
| static std::uint16_t | getQueueMin (std::uint_fast8_t const prio) noexcept |
| Obtain the minimum of free entries of the given event queue since start. | |
| static void | psInit (QSubscrList *const subscrSto, QSignal const maxSignal) noexcept |
| Initializes the publish-subscribe facility for the application. | |
| static void | publish_ (QEvt const *const e, void const *const sender, std::uint_fast8_t const qsId) noexcept |
| Publish event to all subscribers of a given signal e->sig. | |
| static void | evtLoop_ (QActive *act) |
| Event loop thread routine for executing an active object act (defined some in QP ports)Forward Traceability . | |
| static void | publishFromISR (QEvt const *const e, void *const par, void const *const sender) noexcept |
| The "FromISR" variant used in the QP port to "FreeRTOS" . | |
| Static Public Member Functions inherited from QP::QAsm | |
| static constexpr QState | Q_HANDLED () |
| static constexpr QState | Q_UNHANDLED () |
| static constexpr QState | QM_HANDLED () |
| static constexpr QState | QM_UNHANDLED () |
| static constexpr QState | QM_SUPER () |
| static QState | top (void *const me, QEvt const *const e) noexcept |
| Top state handler that ignores all events. | |
Static Public Attributes | |
| static constexpr QTimeEvtCtr | QXTHREAD_NO_TIMEOUT {0U} |
| Static Public Attributes inherited from QP::QAsm | |
| static constexpr QState | Q_RET_SUPER {0U} |
| Return value from a state handler: the event is passed to the superstate (super()). | |
| static constexpr QState | Q_RET_UNHANDLED {1U} |
| Return value from a state handler: the event was not handled due to a guard condition (Q_UNHANDLED()) . | |
| static constexpr QState | Q_RET_HANDLED {2U} |
| Return value from a state handler: the event was handled (Q_HANDLED()) . | |
| static constexpr QState | Q_RET_TRAN {3U} |
| Return value from a state handler: a regular state transition was taken (tran()) . | |
| static constexpr QState | Q_RET_TRAN_HIST {4U} |
| Return value from a state handler: a transition to history was taken (tran_hist()) . | |
| static constexpr QState | Q_RET_IGNORED {5U} |
| Return value from a state handler: the event was ignored (used in QP::QHsm only) . | |
| static constexpr QState | Q_RET_ENTRY {6U} |
| Return value from an entry action: the entry action was executed (used in QP::QMsm only) . | |
| static constexpr QState | Q_RET_EXIT {7U} |
| Return value from an exit action: the exit action was executed (used in QP::QMsm only) . | |
| static constexpr QState | Q_RET_TRAN_INIT {8U} |
| Return value from an initial transition: a nested initial transition was taken (used in QP::QMsm only) . | |
| static constexpr QSignal | Q_EMPTY_SIG {0U} |
| Reserved signal sent to state handler to execute the default case (used in QP::QHsm only) . | |
| static constexpr QSignal | Q_ENTRY_SIG {1U} |
| Reserved signal sent to state handler to execute the entry case (used in QP::QHsm only) . | |
| static constexpr QSignal | Q_EXIT_SIG {2U} |
| Reserved signal sent to state handler to execute the exit case (used in QP::QHsm only) . | |
| static constexpr QSignal | Q_INIT_SIG {3U} |
| Reserved signal sent to state handler to execute the initial transition (used in QP::QHsm only) . | |
| static constexpr QMState const * | QM_STATE_NULL { nullptr } |
| static constexpr QActionHandler const | Q_ACTION_NULL { nullptr } |
| static constexpr std::size_t | MAX_NEST_DEPTH_ {5U} |
| Maximum supported nesting depth of a state machine. | |
Private Member Functions | |
| void | block_ () const noexcept |
| Block QXThread private implementation. | |
| void | unblock_ () const noexcept |
| Unblock QXThread private implementation. | |
| void | teArm_ (QSignal const sig, QTimeEvtCtr const nTicks) noexcept |
| Arm internal time event private implementation. | |
| bool | teDisarm_ () noexcept |
| Disarm internal time event private implementation. | |
| void | stackInit_ (QP::QXThreadHandler const handler, void *const stkSto, std::uint_fast16_t const stkSize) noexcept |
| Initialize the private stack of a given eXtended thread (defined in QXK port) . | |
Static Private Member Functions | |
| static void | timeout_ (QActive *const act) |
| Process timeout in QXThread (either delay or during blocking). | |
Private Attributes | |
| QTimeEvt | m_timeEvt |
| Time event to handle blocking timeouts . | |
Friends | |
| class | QActive |
| class | QTimeEvt |
| class | QXSemaphore |
| class | QXMutex |
| class | QS |
Additional Inherited Members | |
| Public Attributes inherited from QP::QAsm | |
| QAsmAttr | m_state |
| Current state (pointer to the current state-handler function) . | |
| QAsmAttr | m_temp |
| Temporary storage for target/act-table etc. | |
| Protected Member Functions inherited from QP::QActive | |
| QActive (QStateHandler const initial) noexcept | |
| QActive constructor (abstract base class). | |
| Protected Member Functions inherited from QP::QAsm | |
| QAsm () noexcept | |
| Constructor of the QP::QAsm base class. | |
| QState | tran (QStateHandler const target) noexcept |
| Internal helper function to take a state transition in sublclasses of QP::QAsm. | |
| QState | tran_hist (QStateHandler const hist) noexcept |
| Internal helper function to take a state transition to history in sublclasses of QP::QAsm. | |
| QState | super (QStateHandler const superstate) noexcept |
| Internal helper function to indicate superstate of a given state in sublclasses of QP::QAsm. | |
| QState | qm_tran (void const *const tatbl) noexcept |
| Internal helper function to take a state transition in QP::QMsm. | |
| QState | qm_tran_init (void const *const tatbl) noexcept |
| Internal helper function to take an initial transition in QP::QMsm. | |
| QState | qm_tran_hist (QMState const *const hist, void const *const tatbl) noexcept |
| Internal helper function to take a state transition to history in QP::QMsm. | |
| QState | qm_entry (QMState const *const s) noexcept |
| Internal helper function to execute state entry actions in QP::QMsm. | |
| QState | qm_exit (QMState const *const s) noexcept |
| Internal helper function to execute state exit actions in QP::QMsm. | |
eXtended (blocking) thread of the QXK preemptive kernel
Details
QP::QXThread represents the eXtended (blocking) thread of the QXK kernel. Each extended thread in the application must be represented by the corresponding QP::QXThread instance
Usage
The following example illustrates how to instantiate and use an extended thread in your application.
|
explicitnoexcept |
Constructor of an extended-thread.
Details
Performs the first step of QXThread initialization by assigning the thread-handler function and the tick rate at which it will handle the timeouts.
| [in] | handler | the thread-handler function |
| [in] | tickRate | the tick rate for timeouts in this thread (see QXThread_delay() and QTIMEEVT_TICK_X()) |
Usage
The following example illustrates how to invoke QXThread_ctor() in the main() function
Forward Traceability
Definition at line 73 of file qxk_xthr.cpp.
|
overridevirtual |
Take the top-most initial transition in QActive (delegate to QP::QHsm).
Backward Traceability
Forward Traceability
Reimplemented from QP::QActive.
Definition at line 85 of file qxk_xthr.cpp.
|
inlineoverridevirtual |
Takes the top-most initial transition without the initialization parameter (documented and traced together with the other overload under the code UID QP::QAsm::init()).
| [in] | qsId | QS-id of this state machine (for QS local filter) |
Reimplemented from QP::QActive.
|
overridevirtual |
Dispatch an event to QActive (delegate to QP::QHsm).
Backward Traceability
Forward Traceability
Reimplemented from QP::QActive.
Definition at line 93 of file qxk_xthr.cpp.
| void QP::QXThread::start | ( | QPrioSpec const | prioSpec, |
| QEvtPtr *const | qSto, | ||
| std::uint_fast16_t const | qLen, | ||
| void *const | stkSto, | ||
| std::uint_fast16_t const | stkSize, | ||
| void const *const | par = nullptr ) |
Start execution of an eXtended thread and register it with the framework.
Details
Registers the eXtended thread with the framework, initializes its (optional) event queue and its private stack, and makes the thread ready to run. If the QXK kernel is already running (and the scheduler is not locked), the scheduler is invoked.
| [in] | prioSpec | priority specification for the thread (the preemption-threshold part must be 0) |
| [in] | qSto | pointer to the storage for the ring buffer of the event queue (nullptr if the thread does not use an event queue) |
| [in] | qLen | length of the event queue [# QP::QEvtPtr] |
| [in] | stkSto | pointer to the stack storage (must not be nullptr) |
| [in] | stkSize | stack size [bytes] (must be greater than 0) |
| [in] | par | initialization parameter (not used) |
Forward Traceability
Definition at line 349 of file qxk_xthr.cpp.
|
inline |
|
staticnoexcept |
Delay (block) the current extended thread for a specified # ticks.
Details
Blocking delay for the number of clock tick at the associated tick rate.
| [in] | nTicks | number of clock ticks (at the associated rate) to wait for the event to arrive. |
| true | If delay has expired |
| false | If it delay was canceled with QXThread::delayCancel(). |
Definition at line 101 of file qxk_xthr.cpp.
|
noexcept |
Cancel the delay.
Details
Cancel the blocking delay and cause return from the QXThread::delay() function.
| true | If the thread was actually blocked on QXThread::delay() |
| false | Otherwise |
Definition at line 147 of file qxk_xthr.cpp.
|
staticnoexcept |
Obtain a message from the private message queue (block if no messages).
Details
The QXThread_queueGet() operation allows the calling extended thread to receive QP events directly into its own built-in event queue from an ISR, basic thread (AO), or another extended thread.
If QXThread_queueGet() is called when no events are present in the thread's private event queue, the operation blocks the current extended thread until either an event is received, or a user-specified timeout expires.
| [in] | nTicks | number of clock ticks (at the associated rate) to wait for the event to arrive. The value of QXTHREAD_NO_TIMEOUT indicates that no timeout will occur and the queue will block indefinitely. |
| evt | Pointer to the event, if the event was delivered |
| nullptr | Indicates that the queue has timed out |
Definition at line 164 of file qxk_xthr.cpp.
|
privatenoexcept |
Block QXThread private implementation.
Details
Internal implementation of blocking the given extended thread.
Definition at line 257 of file qxk_xthr.cpp.
|
privatenoexcept |
Unblock QXThread private implementation.
Details
Internal implementation of un-blocking the given extended thread.
Definition at line 270 of file qxk_xthr.cpp.
|
staticprivate |
Process timeout in QXThread (either delay or during blocking).
| [in,out] | act | generic QActive* pointer of the thread that times out. |
Definition at line 281 of file qxk_xthr.cpp.
|
privatenoexcept |
Arm internal time event private implementation.
Details
Internal implementation of arming the private time event for a given timeout at a given system tick rate.
Definition at line 293 of file qxk_xthr.cpp.
|
privatenoexcept |
Disarm internal time event private implementation.
Details
Internal implementation of disarming the private time event.
Definition at line 336 of file qxk_xthr.cpp.
|
privatenoexcept |
Initialize the private stack of a given eXtended thread (defined in QXK port) .
|
staticconstexpr |