QP/C++ 8.1.2
Real-Time Event Framework
Loading...
Searching...
No Matches
QP::QActive Class Reference

Active object class (based on the QP::QHsm implementation strategy). More...

#include <qp.hpp>

Inheritance diagram for QP::QActive:
QP::QAsm QP::QActiveDummy QP::QMActive QP::QTicker QP::QXThread

Public Member Functions

void init (void const *const e, std::uint_fast8_t const qsId) override
 Virtual function to take the top-most initial transition in the state machine.
void dispatch (QEvt const *const e, std::uint_fast8_t const qsId) override
 Virtual function to dispatch an event to the state machine.
bool isIn (QStateHandler const stateHndl) noexcept override
 Virtual function to check whether the state machine is in a given state.
QStateHandler getStateHandler () const noexcept override
 Virtual method for getting the current state handler.
QStateHandler childState (QStateHandler const parentHandler) noexcept
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 *par, void const *const sender) noexcept
 The "FromISR" variant used in the QP port to "FreeRTOS".
virtual void init (std::uint_fast8_t const qsId)
 Virtual function to take the top-most initial transition in the state machine (overloaded).
Public Member Functions inherited from QP::QAsm
virtual ~QAsm () noexcept
 Virtual destructor of the QP::QAsm abstract base class.
QStateHandler state () const noexcept
QMState const * stateObj () const noexcept

Static Public Member Functions

static std::uint16_t getQueueUse (std::uint_fast8_t const prio) noexcept
static std::uint16_t getQueueFree (std::uint_fast8_t const prio) noexcept
static std::uint16_t getQueueMin (std::uint_fast8_t const prio) noexcept
static void psInit (QSubscrList *const subscrSto, QSignal const maxSignal) noexcept
 Publish event to all subscribers of a given signal e->sig.
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).
static QActivefromRegistry (std::uint_fast8_t const prio)
static void publishFromISR (QEvt const *e, void *par, void 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.

Protected Member Functions

 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
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.

Private Member Functions

void postFIFO_ (QEvt const *const e, void const *const sender)

Static Private Member Functions

static void multicast_ (QPSet *const subscrSet, QEvt const *const e, void const *const sender)

Private Attributes

std::uint8_t m_prio
 QF-priority [1..QF_MAX_ACTIVE] of this AO.
std::uint8_t m_pthre
 Preemption-threshold [1..QF_MAX_ACTIVE] of this AO.
QACTIVE_THREAD_TYPE m_thread
 Port-dependent representation of the thread of the active object.
QACTIVE_OS_OBJ_TYPE m_osObject
 Port-dependent per-thread object.
QACTIVE_EQUEUE_TYPE m_eQueue
 Port-dependent event-queue type (often QP::QEQueue).

Friends

class QTimeEvt
class QTicker
class QXThread
class QXMutex
class QXSemaphore
class QMActive
class QActiveDummy
class QK
class QXK
class QS
void QF::init ()
void QF::stop ()
int_t QF::run ()
void QF::onStartup ()
void QF::onCleanup ()

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.
Static Public Attributes inherited from QP::QAsm
static constexpr QState Q_RET_SUPER {0U}
static constexpr QState Q_RET_UNHANDLED {1U}
static constexpr QState Q_RET_HANDLED {2U}
static constexpr QState Q_RET_TRAN {3U}
static constexpr QState Q_RET_TRAN_HIST {4U}
static constexpr QState Q_RET_IGNORED {5U}
static constexpr QState Q_RET_ENTRY {6U}
static constexpr QState Q_RET_EXIT {7U}
static constexpr QState Q_RET_TRAN_INIT {8U}
static constexpr QSignal Q_EMPTY_SIG {0U}
static constexpr QSignal Q_ENTRY_SIG {1U}
static constexpr QSignal Q_EXIT_SIG {2U}
static constexpr QSignal Q_INIT_SIG {3U}
static constexpr QMState const * QM_STATE_NULL { nullptr }
static constexpr QActionHandler const Q_ACTION_NULL { nullptr }

Detailed Description

Active object class (based on the QP::QHsm implementation strategy).

Details
Active objects are encapsulated tasks (each containing an event queue and a state machine) that communicate with one another asynchronously by sending and receiving events. Within an active object, events are processed in a run-to-completion (RTC) fashion, while QF encapsulates all the details of thread-safe event exchange and queuing.

QP::QActive represents an active object that uses the QHsm-style implementation strategy for state machines. This strategy is tailored to manual coding, but it is also supported by the QM modeling tool. The resulting code is slower than in the QMsm-style implementation strategy.

Note
QP::QActive is not intended to be instantiated directly, but rather serves as the abstract base class for derivation of active objects in the applications.
See also
QP::QMActive

Backward Traceability

Usage
The following example illustrates how to derive an active object from QP::QActive.

class Philo : public QP::QActive { // <=== inherit QP::QActive
private:
QP::QTimeEvt m_timeEvt;
std::uint8_t m_id;
public:
static Philo inst[N_PHILO];
public:
Philo();
protected:
Q_STATE_DECL(initial);
Q_STATE_DECL(thinking);
Q_STATE_DECL(hungry);
Q_STATE_DECL(eating);
};
Active object class (based on the QP::QHsm implementation strategy).
Definition qp.hpp:492
Time Event class.
Definition qp.hpp:664
#define Q_STATE_DECL(state_)
Definition qp.hpp:379

Forward Traceability

  • DVR_QP_PCLP_1801: Base class has a destructor that is not public virtual; public override or protected non-virtual

Definition at line 492 of file qp.hpp.

Constructor & Destructor Documentation

◆ QActive()

QP::QActive::QActive ( QStateHandler const initial)
explicitprotectednoexcept

QActive constructor (abstract base class).

Parameters
[in]initialpointer to the top-most initial state-handler function in the derived active object

Definition at line 55 of file qf_qact.cpp.

Member Function Documentation

◆ init() [1/2]

void QP::QActive::init ( void const *const e,
std::uint_fast8_t const qsId )
overridevirtual

Virtual function to take the top-most initial transition in the state machine.

Details
Synchronously executes the top-most initial transition in a state machine (must be overridden in the subclasses).

Parameters
[in]epointer to an initialization parameter (might be nullptr)
[in]qsIdQS-id of this state machine (for QS local filter)

Implements QP::QAsm.

Reimplemented in QP::QActiveDummy, QP::QMActive, QP::QTicker, and QP::QXThread.

Definition at line 134 of file qf_qact.cpp.

◆ dispatch()

void QP::QActive::dispatch ( QEvt const *const e,
std::uint_fast8_t const qsId )
overridevirtual

Virtual function to dispatch an event to the state machine.

Details
Synchronously dispatches an event for processing to a state machine (must be overridden in the subclasses). The processing of an event represents one run-to-completion (RTC) step.

Parameters
[in]epointer to the event to be dispatched to the MSM
[in]qsIdQS-id of this state machine (for QS local filter)

Implements QP::QAsm.

Reimplemented in QP::QActiveDummy, QP::QMActive, QP::QTicker, and QP::QXThread.

Definition at line 142 of file qf_qact.cpp.

◆ isIn()

bool QP::QActive::isIn ( QStateHandler const state)
overridevirtualnoexcept

Virtual function to check whether the state machine is in a given state.

Details
Tests if a given state is part of the current active state configuration. Please note that in a hierarchical state machine, to "be in a state" means also to be in a superstate of the state.

Parameters
[in]statepointer to the state-handler function to be checked
Returns
'true' if the state machine "is in" the state and 'false' otherwise
Attention
This function should be called only when the state machine is in a "stable state configuration". Among others, this means that the state machine cannot call it in the middle of its own transition.

Backward Traceability

  • SRS_QP_SM_25: All State Machine Implementation Strategies provided by the QP/C++ Framework might supply a method for checking if a state machine is in a given state.

Implements QP::QAsm.

Reimplemented in QP::QMActive.

Definition at line 150 of file qf_qact.cpp.

◆ getStateHandler()

QStateHandler QP::QActive::getStateHandler ( ) const
overridevirtualnoexcept

Virtual method for getting the current state handler.

Details
This virtual call applies to all subclasses of QP::QAsm, such as: QP::QHsm, QP::QMsm, QP::QActive, and QP::QMActive.

Returns
the current state-handler of the type QP::QStateHandler (pointer to function)
Note
This function can be called in any context (including from a critical section) and also not necessarily in the "stable state configuration". When called during a state transition in the state machine, it returns the source state.

Backward Traceability

  • SRS_QP_SM_26: All State Machine Implementation Strategies provided by the QP/C++ Framework might supply a method for obtaining the current state.

Usage
The following example illustrates how to obtain the current state handler of an Active Object:

QStateHandler handler = myAO->getStateHandler();
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function.
Definition qp.hpp:138

Implements QP::QAsm.

Reimplemented in QP::QActiveDummy, and QP::QMActive.

Definition at line 165 of file qf_qact.cpp.

◆ childState()

QStateHandler QP::QActive::childState ( QStateHandler const parentHandler)
noexcept

Definition at line 155 of file qf_qact.cpp.

◆ setAttr()

void QP::QActive::setAttr ( std::uint32_t attr1,
void const * attr2 = nullptr )

Generic setting of additional attributes (defined in some QP ports).

Forward Traceability

◆ start()

void QP::QActive::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.

Details
Starts execution of the AO and registers the AO with the framework.

Parameters
[in]prioSpecpriority specification for the AO (See QP::QPrioSpec)
[in]qStopointer to the storage for the ring buffer of the event queue
[in]qLenlength of the event queue [# QP::QEvt* pointers]
[in]stkStopointer to the stack storage (might be NULL)
[in]stkSizestack size [bytes]
[in]parinitialization parameter (optional)

Usage
The following example shows starting an AO when a per-task stack is NOT needed:

#include "qpcpp.hpp"
int main() {
QP::QF::init(); // initialize the framework and the underlying RT kernel
BSP::init(); // initialize the Board Support Package
. . .
// instantiate and start the active objects...
static QP::QEvt const *blinkyQueueSto[10];
APP::AO_Blinky->start(
1U, // QP prio. of the AO
blinkyQueueSto, // event queue storage
Q_DIM(blinkyQueueSto), // queue length [events]
nullptr, 0U); // no stack storage
. . .
return QP::QF::run(); // run the QF application
}
Event class.
Definition qp.hpp:101
void init()
QF initialization.
Definition qv.cpp:96
int_t run()
Transfers control to QF to run the application.
Definition qv.cpp:109
#define Q_DIM(array_)
Helper macro to calculate static dimension of a 1-dim array.
Definition qp.hpp:90
QP/C++ Framework in C++ interface including the backwards-compatibility layer.

Forward Traceability

  • DVR_QP_MP2_R10_1_1: Rule 10.1.1(Advisory): The target type of a pointer or lvalue reference parameter should be const-qualified appropriately
  • DVR_QP_PCLP_1933: call to unqualified virtual function from non-static member function

Definition at line 212 of file qv.cpp.

◆ stop()

void QP::QActive::stop ( )

Stops execution of an active object and removes it from the framework's supervision.

Attention
QActive::stop() must be called only from the AO that is about to stop its execution. By that time, any pointers or references to the AO are considered invalid (dangling) and it becomes illegal for the rest of the application to post events to the AO.

Forward Traceability

Definition at line 278 of file qutest.cpp.

◆ register_()

void QP::QActive::register_ ( )
noexcept

Register this active object to be managed by the framework.

Details
This function adds a given active object to the active objects managed by the QF framework. It should not be called by the application directly, only through the function QActive::start().

Forward Traceability

Definition at line 68 of file qf_qact.cpp.

◆ unregister_()

void QP::QActive::unregister_ ( )
noexcept

Un-register the active object from the framework.

Details
This function un-registers a given active object from the active objects managed by the QF framework. It should not be called by the QP ports.

Note
The active object that is removed from the framework can no longer participate in any event exchange.

Forward Traceability

Definition at line 116 of file qf_qact.cpp.

◆ post_()

void QP::QActive::post_ ( QEvt const *const e,
void const *const sender )
inlinenoexcept

Posts an event e directly to the event queue of the active object using the First-In-First-Out (FIFO) policy.

Details
Direct event posting is the simplest asynchronous communication method available in QF.

Parameters
[in]epointer to the event to be posted
[in]senderpointer to a sender object (used in QS only)
Attention
This operation should be called via the macros POST() and POST_X(). This is because the last parameter sender might be defined/provided only in the Spy build configuration (see Q_SPY). The macros ignore the sender parameter outside the Spy configuration, so the same code builds correctly in all configurations.
Note
This function delegates to QP::QActive::postx_() with the margin_ parameter set to QF::NO_MARGIN

Usage

extern QP::QActive * const AO_Table;
. . .
Q_STATE_DEF(Philo, hungry) {
QP::QState status_;
switch (e->sig) {
case Q_ENTRY_SIG: {
TableEvt const *pe = QP::QF::q_new<TableEvt>(HUNGRY_SIG, m_id);
AO_Table->POST(pe, this); // <===
status_ = Q_RET_HANDLED;
break;
}
. . .
}
return status_;
}
static constexpr QSignal Q_ENTRY_SIG
Definition qp.hpp:191
static constexpr QState Q_RET_HANDLED
Definition qp.hpp:176
evtT_ * q_new(QSignal const sig, Args... args)
Definition qp.hpp:833
std::uint_fast8_t QState
Type returned from state-handler functions.
Definition qp.hpp:134

Forward Traceability

Definition at line 537 of file qp.hpp.

◆ postx_()

bool QP::QActive::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.

Details
Direct event posting is the simplest asynchronous communication method available in QF.

Parameters
[in]epointer to the event to be posted
[in]marginnumber of required free slots in the queue after posting the event or QF::NO_MARGIN.
[in]senderpointer to a sender object (used in QS only)
Returns
'true' (success) if the posting succeeded (with the provided margin) and 'false' (failure) when the posting fails.
Attention
This operation should be called via the macros POST() and POST_X(). This is because the last parameter sender might be defined/provided only in the Spy build configuration (see Q_SPY). The macros ignore the sender parameter outside the Spy configuration, so the same code builds correctly in all configurations.
Note
This function might be implemented differently in various QP/C++ ports. The provided implementation assumes that the QP::QEQueue class is used for the QP::QActive event queue.

Usage

extern QP::QActive * const AO_Table;
. . .
Q_STATE_DEF(Philo, hungry) {
QP::QState status_;
switch (e->sig) {
case Q_ENTRY_SIG: {
TableEvt const *pe = QP::QF::q_new<TableEvt>(HUNGRY_SIG, m_id);
AO_Table->POST_X(pe, 5U, this); // <===
status_ = Q_RET_HANDLED;
break;
}
. . .
}
return status_;
}

Forward Traceability

Definition at line 49 of file qf_actq.cpp.

◆ postLIFO()

void QP::QActive::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.

Details
The LIFO policy should be used only for self-posting and with caution because it alters order of events in the queue.

Parameters
[in]epointer to the event to be posted
Note
This function might be implemented differently in various QP/C++ ports. The provided implementation assumes that the QP::QEQueue class is used for the QActive event queue.
See also
QP::QActive::post_()

Forward Traceability

Definition at line 126 of file qf_actq.cpp.

◆ get_()

QEvt const * QP::QActive::get_ ( )
noexcept

Get an event from the event queue of an active object.

Details
The behavior of this function depends on the kernel used in the QF port. For built-in kernels (QV or QK) the function can be called only when the queue is not empty, so it doesn't block. For a blocking kernel/OS the function can block and wait for delivery of an event.

Returns
A pointer to the received event. The returned pointer is guaranteed to be valid (can't be NULL).
Note
This function might be implemented differently in various QP/C++ ports. The provided implementation assumes that the QP::QEQueue class is used for the QActive event queue.

Forward Traceability

Definition at line 197 of file qf_actq.cpp.

◆ getQueueUse()

std::uint16_t QP::QActive::getQueueUse ( std::uint_fast8_t const prio)
staticnoexcept

Definition at line 316 of file qf_actq.cpp.

◆ getQueueFree()

std::uint16_t QP::QActive::getQueueFree ( std::uint_fast8_t const prio)
staticnoexcept

Definition at line 349 of file qf_actq.cpp.

◆ getQueueMin()

std::uint16_t QP::QActive::getQueueMin ( std::uint_fast8_t const prio)
staticnoexcept

Definition at line 368 of file qf_actq.cpp.

◆ psInit()

void QP::QActive::psInit ( QSubscrList *const subscrSto,
QSignal const maxSignal )
staticnoexcept

Publish event to all subscribers of a given signal e->sig.

Details
This function posts (using the FIFO policy) the event e to all active objects that have subscribed to the signal e->sig, which is called multicasting. The multicasting performed in this function is very efficient based on reference-counting inside the published event ("zero-copy" event multicasting). This function is designed to be callable from any part of the system, including ISRs, device drivers, and active objects.

Note
To avoid any unexpected re-ordering of events posted into AO queues, the event multicasting is performed with scheduler locked. However, the scheduler is locked only up to the priority level of the highest-priority subscriber, so any AOs of even higher priority, which did not subscribe to this event are not affected.

Forward Traceability

Definition at line 51 of file qf_ps.cpp.

◆ publish_()

void QP::QActive::publish_ ( QEvt const *const e,
void const *const sender,
std::uint_fast8_t const qsId )
staticnoexcept

Publish event to all subscribers of a given signal e->sig.

Details
This function posts (using the FIFO policy) the event e to all active objects that have subscribed to the signal e->sig, which is called multicasting. The multicasting performed in this function is very efficient based on reference-counting inside the published event ("zero-copy" event multicasting). This function is designed to be callable from any part of the system, including ISRs, device drivers, and active objects.

Note
To avoid any unexpected re-ordering of events posted into AO queues, the event multicasting is performed with scheduler locked. However, the scheduler is locked only up to the priority level of the highest-priority subscriber, so any AOs of even higher priority, which did not subscribe to this event are not affected.
Attention
This operation is typically used via macro PUBLISH(). This is because the last parameter qsId might be defined/provided only in the Spy build configuration (see Q_SPY). The macro ignores the qsId parameter outside the Spy configuration, so the same code builds correctly in all configurations.

Usage

Q_STATE_DEF(Philo, eating) {
QP::QState status_;
switch (e->sig) {
. . .
case Q_EXIT_SIG: {
m_timeEvt.disarm();
TableEvt const *pe = QP::QF::q_new<TableEvt>(DONE_SIG, m_id);
QP::QActive::PUBLISH(pe, this); // <===
status_ = Q_RET_HANDLED;
break;
}
. . .
}
return status_;
}
static constexpr QSignal Q_EXIT_SIG
Definition qp.hpp:192
#define Q_STATE_DEF(subclass_, state_)
Definition qp.hpp:383

Forward Traceability

Definition at line 71 of file qf_ps.cpp.

◆ subscribe()

void QP::QActive::subscribe ( QSignal const sig) const
noexcept

Subscribes for delivery of signal sig to the active object.

Details
This function is part of the Publish-Subscribe event delivery mechanism available in QF. Subscribing to an event means that the framework will start posting all published events with a given signal sig to the event queue of the active object.

Parameters
[in]sigevent signal to subscribe

Usage
The following example shows how the Table active object subscribes to three signals in the initial transition:

Q_STATE_DEF(Philo, initial) {
. . .
subscribe(EAT_SIG); // <===
subscribe(TEST_SIG); // <===
. . .
return tran(&thinking);
}
void subscribe(QSignal const sig) const noexcept
Subscribes for delivery of signal sig to the active object.
Definition qf_ps.cpp:185
QState tran(QStateHandler const target) noexcept
Internal helper function to take a state transition in sublclasses of QP::QAsm.
Definition qp.hpp:235
#define Q_UNUSED_PAR(par_)
Helper macro to mark unused parameters of functions.
Definition qp.hpp:89

Forward Traceability

Definition at line 185 of file qf_ps.cpp.

◆ unsubscribe()

void QP::QActive::unsubscribe ( QSignal const sig) const
noexcept

Unsubscribes from the delivery of signal sig to the active object.

Details
This function is part of the Publish-Subscribe event delivery mechanism available in QF. Un-subscribing from an event means that the framework will stop posting published events with a given signal sig to the event queue of the active object.

Parameters
[in]sigevent signal to unsubscribe
Note
Due to the latency of event queues, an active object should NOT assume that a given signal sig will never be dispatched to the state machine of the active object after un-subscribing from that signal. The event might be already in the queue, or just about to be posted and the un-subscribe operation will not flush such events.
Un-subscribing from a signal that has never been subscribed in the first place is considered an error and QF will raise an assertion.

Forward Traceability

Definition at line 216 of file qf_ps.cpp.

◆ unsubscribeAll()

void QP::QActive::unsubscribeAll ( ) const
noexcept

Unsubscribes from the delivery of all signals to the active object.

Details
This function is part of the Publish-Subscribe event delivery mechanism available in QF. Un-subscribing from all events means that the framework will stop posting any published events to the event queue of the active object.

Note
Due to the latency of event queues, an active object should NOT assume that no events will ever be dispatched to the state machine of the active object after un-subscribing from all events. The events might be already in the queue, or just about to be posted and the un-subscribe operation will not flush such events. Also, the alternative event-delivery mechanisms, such as direct event posting or time events, can be still delivered to the event queue of the active object.

Forward Traceability

Definition at line 245 of file qf_ps.cpp.

◆ defer()

bool QP::QActive::defer ( QEQueue *const eq,
QEvt const *const e ) const
noexcept

Defer an event to a given separate event queue.

Details
This function is part of the event deferral support. An active object uses this function to defer an event e to the QF-supported native event queue eq. QF correctly accounts for another outstanding reference to the event and will not recycle the event at the end of the RTC step. Later, the active object might recall one event at a time from the event queue.

Remarks
An active object can use multiple event queues to defer events of different kinds.
Parameters
[in]eqpointer to a "raw" thread-safe queue to recall an event from.
[in]epointer to the event to be deferred
Returns
'true' (success) when the event could be deferred and 'false' (failure) if event deferral failed due to overflowing the queue.

Forward Traceability

Definition at line 48 of file qf_defer.cpp.

◆ recall()

bool QP::QActive::recall ( QEQueue *const eq)
noexcept

Recall a deferred event from a given event queue.

Details
This function is part of the event deferral support. An active object uses this function to recall a deferred event from a given QF event queue. Recalling an event means that it is removed from the deferred event queue eq and posted (LIFO) to the event queue of the active object.

Parameters
[in]eqpointer to a "raw" thread-safe queue to recall an event from.
Returns
'true' if an event has been recalled and 'false' if not.
Note
An active object can use multiple event queues to defer events of different kinds.

Forward Traceability

Definition at line 81 of file qf_defer.cpp.

◆ flushDeferred()

std::uint16_t QP::QActive::flushDeferred ( QEQueue *const eq,
std::uint_fast16_t const num = 0xFFFFU ) const
noexcept

Flush the specified deferred queue eq.

Details
This function is part of the event deferral support. An active object can use this function to flush a given QF event queue. The function makes sure that the events are not leaked.

Parameters
[in]eqpointer to a "raw" thread-safe queue to flush.
[in]numnumber of events to flush (might exceed the capacity of the queue).
Returns
the number of events actually flushed from the queue.

Forward Traceability

Definition at line 135 of file qf_defer.cpp.

◆ getPrio()

std::uint8_t QP::QActive::getPrio ( ) const
inlinenoexcept

Definition at line 571 of file qp.hpp.

◆ evtLoop_()

void QP::QActive::evtLoop_ ( QActive * act)
static

Event loop thread routine for executing an active object act (defined some in QP ports).

Forward Traceability

◆ fromRegistry()

QActive * QP::QActive::fromRegistry ( std::uint_fast8_t const prio)
static

Definition at line 160 of file qf_qact.cpp.

◆ getThread() [1/2]

QACTIVE_THREAD_TYPE const & QP::QActive::getThread ( ) const &
inline

Definition at line 578 of file qp.hpp.

◆ getThread() [2/2]

QACTIVE_THREAD_TYPE const & QP::QActive::getThread ( ) const &&
delete

◆ setThread()

void QP::QActive::setThread ( QACTIVE_THREAD_TYPE const & thr)
inlinenoexcept

Definition at line 585 of file qp.hpp.

◆ getOsObject() [1/2]

QACTIVE_OS_OBJ_TYPE const & QP::QActive::getOsObject ( ) const &
inline

Definition at line 591 of file qp.hpp.

◆ getOsObject() [2/2]

QACTIVE_OS_OBJ_TYPE const & QP::QActive::getOsObject ( ) const &&
delete

◆ postFromISR()

virtual bool QP::QActive::postFromISR ( QEvt const *const e,
std::uint_fast16_t const margin,
void * par,
void const *const sender )
virtualnoexcept

The "FromISR" variant used in the QP port to "FreeRTOS".

◆ publishFromISR()

void QP::QActive::publishFromISR ( QEvt const * e,
void * par,
void const * sender )
staticnoexcept

The "FromISR" variant used in the QP port to "FreeRTOS".

◆ postFIFO_()

void QP::QActive::postFIFO_ ( QEvt const *const e,
void const *const sender )
private

Definition at line 261 of file qf_actq.cpp.

◆ multicast_()

void QP::QActive::multicast_ ( QPSet *const subscrSet,
QEvt const *const e,
void const *const sender )
staticprivate

Definition at line 127 of file qf_ps.cpp.

◆ init() [2/2]

void QP::QAsm::init ( std::uint_fast8_t const qsId)
virtual

Virtual function to take the top-most initial transition in the state machine (overloaded).

Details
Synchronously executes the top-most initial transition in a state machine. This overloaded version takes no initialization parameter.

Parameters
[in]qsIdQS-id of this state machine (for QS local filter)

Reimplemented from QP::QAsm.

Reimplemented in QP::QMActive, QP::QTicker, and QP::QXThread.

Definition at line 216 of file qf_act.cpp.

◆ QTimeEvt

friend class QTimeEvt
friend

Definition at line 623 of file qp.hpp.

◆ QTicker

friend class QTicker
friend

Definition at line 624 of file qp.hpp.

◆ QXThread

friend class QXThread
friend

Definition at line 625 of file qp.hpp.

◆ QXMutex

friend class QXMutex
friend

Definition at line 626 of file qp.hpp.

◆ QXSemaphore

friend class QXSemaphore
friend

Definition at line 627 of file qp.hpp.

◆ QMActive

friend class QMActive
friend

Definition at line 628 of file qp.hpp.

◆ QActiveDummy

friend class QActiveDummy
friend

Definition at line 629 of file qp.hpp.

◆ QK

friend class QK
friend

Definition at line 630 of file qp.hpp.

◆ QXK

friend class QXK
friend

Definition at line 631 of file qp.hpp.

◆ QS

friend class QS
friend

Definition at line 632 of file qp.hpp.

◆ QF::init

void QF::init ( )
friend

◆ QF::stop

void QF::stop ( )
friend

◆ QF::run

int_t QF::run ( )
friend

◆ QF::onStartup

void QF::onStartup ( )
friend

◆ QF::onCleanup

void QF::onCleanup ( )
friend

Member Data Documentation

◆ m_prio

std::uint8_t QP::QActive::m_prio
private

QF-priority [1..QF_MAX_ACTIVE] of this AO.

See also
QP::QPrioSpec

Definition at line 494 of file qp.hpp.

◆ m_pthre

std::uint8_t QP::QActive::m_pthre
private

Preemption-threshold [1..QF_MAX_ACTIVE] of this AO.

See also
QP::QPrioSpec

Definition at line 495 of file qp.hpp.

◆ m_thread

QACTIVE_THREAD_TYPE QP::QActive::m_thread
private

Port-dependent representation of the thread of the active object.

Details
This data might be used in various ways, depending on the QF port. In some ports me->thread is used store the thread handle. In other ports me->m_thread can be a pointer to the Thread-Local-Storage (TLS).

Definition at line 498 of file qp.hpp.

◆ m_osObject

QACTIVE_OS_OBJ_TYPE QP::QActive::m_osObject
private

Port-dependent per-thread object.

Details
This data might be used in various ways, depending on the QF port. In some ports me->osObject is used to block the calling thread when the native QF queue is empty. In other QF ports the OS-dependent object might be used differently.

Definition at line 502 of file qp.hpp.

◆ m_eQueue

QACTIVE_EQUEUE_TYPE QP::QActive::m_eQueue
private

Port-dependent event-queue type (often QP::QEQueue).

Details
The type of the queue depends on the underlying operating system or a kernel. Many kernels support "message queues" that can be adapted to deliver QF events to the active object. Alternatively, QF provides a native event queue implementation that can be used as well.

Note
The native QF event queue is configured by defining the macro QP::QACTIVE_EQUEUE_TYPE as QP::QEQueue.

Definition at line 506 of file qp.hpp.


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