QF Active Object Framework namespace. More...
Classes | |
| class | Attr |
| Private attributes of the QF framework. More... | |
Functions | |
| void | QF_INIT_CFGCHK_ () |
| QF initialization with the configuration-specific name (QP configuration check). | |
| void | init () |
| QF initialization. | |
| void | stop () |
| Invoked by the application layer to stop the QF framework and return control to the OS/Kernel (used in some QF ports). | |
| int_t | run () |
| Transfers control to QF to run the application. | |
| void | onStartup () |
| Startup QF callback. | |
| void | onCleanup () |
| Cleanup QF callback. | |
| void | psInit (QSubscrList *const subscrSto, QSignal const maxSignal) noexcept |
| void | publish_ (QEvt const *const e, void const *const sender, std::uint_fast8_t const qsId) noexcept |
| std::uint_fast16_t | getQueueMin (std::uint_fast8_t const prio) noexcept |
| void | tick (std::uint_fast8_t const tickRate, void const *const sender) noexcept |
| QPrioSpec | prioSpec (std::uint8_t const prio, std::uint8_t const pthre) noexcept |
| Create a QP::QPrioSpec object to specify priority of an AO or a thread. | |
| void | poolInit (void *const poolSto, std::uint_fast32_t const poolSize, std::uint_fast16_t const evtSize) noexcept |
| Event pool initialization for dynamic allocation of events. | |
| std::uint16_t | poolGetMaxBlockSize () noexcept |
| Obtain the block size of any registered event pools. | |
| std::uint16_t | getPoolUse (std::uint_fast8_t const poolNum) noexcept |
| Obtain the number of used entries of the given event pool or of all event pools. | |
| std::uint16_t | getPoolFree (std::uint_fast8_t const poolNum) noexcept |
| Obtain the number of free entries of the given event pool. | |
| std::uint16_t | getPoolMin (std::uint_fast8_t const poolNum) noexcept |
| Obtain the minimum of free entries of the given event pool. | |
| QEvt * | newX_ (std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, QSignal const sig) noexcept |
| Internal QF implementation of creating new mutable (dynamic) event. | |
| void | gc (QEvt const *const e) noexcept |
| Recycle a mutable (dynamic) event. | |
| QEvt const * | newRef_ (QEvt const *const e, QEvt const *const evtRef) noexcept |
| Internal QF implementation of creating new event reference. | |
| void | deleteRef_ (QEvt const *const evtRef) noexcept |
| Internal QF implementation of deleting event reference. | |
| template<class evtT_, typename... Args> | |
| evtT_ * | q_new (QSignal const sig, Args... args) |
| Function template to allocate a dynamic event and asserting successful allocation. | |
| template<class evtT_, typename... Args> | |
| evtT_ * | q_new_x (std::uint_fast16_t const margin, QSignal const sig, Args... args) |
| Function template to allocate a dynamic event without asserting successful allocation. | |
| template<class evtT_> | |
| void | q_new_ref (QP::QEvt const *const e, evtT_ const *&evtRef) |
| Create a new reference of the current event e. | |
| template<class evtT_> | |
| void | q_delete_ref (evtT_ const *&evtRef) |
| Delete a new reference of the current event e. | |
| QEvt * | newXfromISR_ (std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, QSignal const sig) noexcept |
| void | gcFromISR (QEvt const *e) noexcept |
Variables | |
| constexpr std::uint_fast16_t | NO_MARGIN {0xFFFFU} |
| Special value of margin that causes asserting failure in case event allocation or event posting fails. | |
| QF::Attr | priv_ |
| pthread_mutex_t | critSectMutex_ |
| int_t | critSectNest_ |
QF Active Object Framework namespace.
Backward Traceability
| void QP::QF::QF_INIT_CFGCHK_ | ( | ) |
QF initialization with the configuration-specific name (QP configuration check).
Details
The QF initialization implemented in the QP port/kernel. The name QF_INIT_CFGCHK_ is a macro defined in qp_cfgchk.hpp, which expands to a name that encodes the QP configuration (e.g., QF_816U_a32t01p03e4q1m2s00). The inline function QP::QF::init() called by the application calls QP::QF::QF_INIT_CFGCHK_(). If the QP library has been built with a different configuration than the application, the names differ and the build fails at link time.
Backward Traceability
Forward Traceability
|
inline |
QF initialization.
Details
Initializes QF and must be called exactly once before any other QF function. Typically, QF::init() is called from main() even before initializing the Board Support Package (BSP).
Backward Traceability
Forward Traceability
| void QP::QF::stop | ( | ) |
Invoked by the application layer to stop the QF framework and return control to the OS/Kernel (used in some QF ports).
Details
This function stops the QF application. After calling this function, QF attempts to stop the application gracefully. This graceful shutdown might take some time to complete. The typical use of this function is for terminating the QF application to return to the operating system or for handling fatal errors that require shutting down (and possibly resetting) the system.
Backward Traceability
Forward Traceability
| int_t QP::QF::run | ( | ) |
Transfers control to QF to run the application.
Details
QF::run() is typically called from your startup code after you initialize the QF and start at least one active object with QActive::start().
In the built-in kernels, QF::run() begins by flushing the QS software-tracing buffer (QS_FLUSH(), only with Q_SPY), which contains the trace data produced during the startup. If the startup produces more trace data than the QS buffer can hold (e.g., many active objects), the Application can call QS_FLUSH() between the QActive::start() calls.
| no-return | Typically in embedded systems QF::run() does not return |
| status | In case QF runs on top of a General-Purpose OS (GPOS), QF::run() returns the error status with value 0 representing success |
Backward Traceability
Forward Traceability
|
callbackcrit-sect |
Startup QF callback.
Details
The purpose of the QF_onStartup() callback is to configure and enable hardware interrupts. The callback is invoked from QF_run(), right before starting the underlying real-time kernel. By that time, the application is considered ready to receive and service interrupts.
This function is application-specific and is not implemented in QF, but rather in the Board Support Package (BSP) for the given application.
Backward Traceability
Forward Traceability
|
callback |
Cleanup QF callback.
Details
QP::QF::onCleanup() is called in some QF ports before QF returns to the underlying real-time kernel or operating system.
This function is strongly platform-specific and is not implemented in the QF, but either in the QF port or in the Board Support Package (BSP) for the given application. Some QF ports might not require implementing QF_onCleanup() at all, because many embedded applications don't have anything to exit to.
Backward Traceability
Forward Traceability
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
Create a QP::QPrioSpec object to specify priority of an AO or a thread.
| [in] | prio | QF priority [1..QF_MAX_ACTIVE] |
| [in] | pthre | Preemption threshold [1..QF_MAX_ACTIVE] |
| prio-spec | The combined 16-bit priority specification (prio in bits [0..7] and pthre in bits [8..15]). |
Forward Traceability
Definition at line 54 of file qf_qact.cpp.
|
noexcept |
Event pool initialization for dynamic allocation of events.
Details
This function initializes one event pool at a time and must be called exactly once for each event pool before the pool can be used.
| [in] | poolSto | pointer to the storage for the event pool |
| [in] | poolSize | size of the storage for the pool in bytes |
| [in] | evtSize | the block-size of the pool in bytes, which determines the maximum size of events that can be allocated from the pool. |
You may initialize multiple event pools by issuing consecutive calls to QF::poolInit(). For correctness and to simplify the internal implementation, event pools must be initialized in ascending order of event-block size. The total number of initialized pools must not exceed QF_MAX_EPOOL. (If QF_MAX_EPOOL is configured to 0, the framework does not support mutable events.)
To ensure proper alignment of memory blocks within each pool buffer, the framework provides the helper macro QF_MPOOL_EL().
Usage
Backward Traceability
Forward Traceability
Definition at line 51 of file qf_dyn.cpp.
|
noexcept |
Obtain the block size of any registered event pools.
Details
Obtain the block size of any registered event pools
Forward Traceability
Definition at line 88 of file qf_dyn.cpp.
|
noexcept |
Obtain the number of used entries of the given event pool or of all event pools.
Details
This function obtains the number of blocks currently in use (allocated) in the given event pool, or the sum of the used blocks in all initialized event pools.
| [in] | poolNum | event pool ID in the range 1..max_pool, where max_pool is the number of event pools initialized with the function QF::poolInit(). The special value 0 requests the sum over all initialized event pools. |
| use | The number of used blocks in the given event pool (or in all event pools) |
Forward Traceability
|
noexcept |
Obtain the number of free entries of the given event pool.
Details
This function obtains the number of blocks currently free (available for allocation) in the given event pool.
| [in] | poolNum | event pool ID in the range 1..max_pool, where max_pool is the number of event pools initialized with the function QF::poolInit(). |
| free | The number of free blocks in the given event pool |
Forward Traceability
|
noexcept |
Obtain the minimum of free entries of the given event pool.
Details
This function obtains the minimum number of free blocks in the given event pool since this pool has been initialized by a call to QF_poolInit().
| [in] | poolNum | event pool ID in the range 1..max_pool, where max_pool is the number of event pools initialized with the function QF_poolInit(). |
| min | The minimum number of unused blocks in the given event pool |
Backward Traceability
Forward Traceability
|
noexceptinternal |
Internal QF implementation of creating new mutable (dynamic) event.
Details
Allocates an event dynamically from one of the QF event pools.
| [in] | evtSize | the size (in bytes) of the event to allocate |
| [in] | margin | the number of unallocated events still available in a given event pool after the allocation completes. The special value QF::NO_MARGIN means that this function will assert if allocation fails. |
| [in] | sig | the signal to be assigned to the allocated event |
| evt | Pointer to the newly allocated event. |
| NULL | Only if margin != QF::NO_MARGIN and the event cannot be allocated with the specified margin still available in the given pool. |
Backward Traceability
Forward Traceability
Definition at line 193 of file qf_dyn.cpp.
|
noexcept |
Recycle a mutable (dynamic) event.
Details
This function implements a simple garbage collector for the mutable events. Only mutable events are candidates for recycling. (A mutable event is allocated from an event-pool, which is determined as non-zero QEvt::getPoolId_(e).) Next, the function decrements the reference counter of the event (e->refCtr_). It recycles the event only if the counter drops to zero (meaning that no more references are outstanding for this event). The mutable event is recycled by returning it to the pool from which it was initially allocated.
| [in] | e | pointer to the event to recycle |
Backward Traceability
Forward Traceability
Definition at line 267 of file qf_dyn.cpp.
Internal QF implementation of creating new event reference.
Details
Creates and returns a new reference to the current event e
| [in] | e | pointer to the current event |
| [in] | evtRef | the event reference |
| ref | The newly created reference to the event e |
Backward Traceability
Forward Traceability
Definition at line 322 of file qf_dyn.cpp.
|
noexceptinternal |
Internal QF implementation of deleting event reference.
Details
Deletes an existing reference to the event e
| [in] | evtRef | the event reference |
Backward Traceability
Forward Traceability
Definition at line 364 of file qf_dyn.cpp.
|
inline |
Function template to allocate a dynamic event and asserting successful allocation.
Details
This function template allocates a mutable (dynamic) event and asserts that the allocation was successful. The caller of this template does not need to check for validity of the returned event pointer. However, the QP/C++ Application is responsible for sizing the event pools adequately. (This is part of event-delivery guarantee.)
See also
| evtT_ | event class (class name) of the event to allocate |
| [in] | sig | signal to assign to the newly allocated event |
| [in] | args | additional arguments passed to the init() member function of the event class (#QEVT_PAR_INIT configured) |
| pointer | A valid event pointer of the type evtT_*. |
Usage
The following example illustrates non-variadic version of the q_new<evtT> template (when #QEVT_PAR_INIT is NOT defined):
The following example illustrates variadic version of the q_new<evtT> template (when #QEVT_PAR_INIT IS defined):
Backward Traceability
Forward Traceability
|
inline |
Function template to allocate a dynamic event without asserting successful allocation.
Details
This template allocates a mutable (dynamic) event, but only if the corresponding event pool has at least margin of free events left. If the event pool has insufficient number of events left, the template returns nullptr. The caller of this template is responsible for checking the returned event pointer for nullptr.
| evtT_ | event class (class name) of the event to allocate |
| [in] | margin | number of events that must remain available in the given pool after this allocation. The special value ::QF_NO_MARGIN causes asserting failure in case event allocation fails. |
| [in] | sig | signal to assign to the newly allocated event |
| [in] | args | additional arguments passed to the init() member function of the event class (#QEVT_PAR_INIT configured) |
| pointer | An event pointer of the type evtT_* |
| `nullptr` | if the event cannot be allocated with the specified margin of events still left in the event pool. |
Usage
The following example illustrates non-variadic version of the q_new_x<evtT> template (when #QEVT_PAR_INIT is NOT defined):
The following example illustrates variadic version of the q_new_x<evtT> template (when #QEVT_PAR_INIT IS defined):
Usage
The example examples/posix-win32/reminder2 illustrates the use of QP::QF::q_new_x().
See also
Backward Traceability
Forward Traceability
|
inline |
Create a new reference of the current event e.
Details
The current event processed by an Active Object is available only for the duration of the run-to-completion (RTC) step. After that step, the current event is no longer available and the framework might recycle (garbage-collect) the event. The function template QP::QF::q_new_ref() explicitly creates a new reference to the current event that can be stored and used beyond the current RTC step, until the reference is explicitly recycled by means of the function template QP::QF::q_delete_ref().
See also
| evtT_ | event class (class name) of the event to allocate |
| [in] | e | event to create a reference to |
| [in,out] | evtRef | reference object (of the type evtT_* |
This function template does not return a value, but it modifies the evtRef parameter.
Usage
The example examples/posix-win32/defer illustrates the use of QP::QF::q_new_ref()
Forward Traceability
Application-level state machines must not internally poll or block for events.
Application-level state machines must not use the current event after the dispatch.
|
inline |
Delete a new reference of the current event e.
Details
Every event reference created with the function template QP::QF::q_new_ref() needs to be eventually deleted by means of the function template QP::QF::q_delete_ref() to avoid leaking the event.
See also
| evtT_ | event class (class name) of the event to allocate |
| [in,out] | evtRef | event reference to delete |
This function template does not return a value, but it modifies the evtRef parameter.
Usage
The example examples/posix-win32/defer illustrates the use of QP::QF::q_delete_ref()
Forward Traceability
|
constexpr |
Special value of margin that causes asserting failure in case event allocation or event posting fails.
Backward Traceability
| Attr QP::QF::priv_ |
Definition at line 51 of file qf_qact.cpp.