QP/C
Functions
qa_fifo.c File Reference

QActive_postFIFO() definition. More...

#include "qf_pkg.h"
#include "qassert.h"

Go to the source code of this file.

Functions

void QActive_postFIFO (QActive *me, QEvent const *e, void const *sender)
 Posts an event e directly to the event queue of the acitve object me using the First-In-First-Out (FIFO) policy.

Detailed Description

QActive_postFIFO() definition.

Note:
this source file is only included in the QF library when the native QF active object queue is used (instead of a message queue of an RTOS).

Definition in file qa_fifo.c.


Function Documentation

void QActive_postFIFO ( QActive me,
QEvent const *  e,
void const *  sender 
)

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

Note:
this function should be called only via the macro QACTIVE_POST

Direct event posting is the simplest asynchronous communication method available in QF. The following example illustrates how the Philo active object posts directly the HUNGRY event to the Table active object.

extern QActive *AO_Table;

QState Philosopher_hungry(Philosopher *me, QEvent const *e) {
    TableEvt *pe;
    switch (e->sig) {
        case Q_ENTRY_SIG: {
            pe = Q_NEW(TableEvt, HUNGRY_SIG); /* dynamically allocate event */
            pe->philNum = me->num;
            QActive_postFIFO(AO_Table, (QEvent *)pe);     /* direct posting */
            return Q_HANDLED();
        }
        . . .
    }
    return Q_SUPER(&QHsm_top);
}
Note:
The producer of the event (Philo in this case) must only "know" the recipient (Table) by a generic (QActive *AO_Table) pointer, but the specific definition of the Table structure is not required.
Direct event posting should not be confused with direct event dispatching. In contrast to asynchronous event posting through event queues, direct event dispatching is synchronous. Direct event dispatching occurs when you call QHsm_dispatch(), or QFsm_dispatch() function.

Definition at line 46 of file qa_fifo.c.

References QActive::eQueue, Q_ASSERT, QACTIVE_EQUEUE_SIGNAL_, QF_EVT_POOL_ID_, QF_EVT_REF_CTR_, QF_EVT_REF_CTR_INC_, QF_PTR_AT_, QS_aoObj_, QS_BEGIN_NOCRIT_, QS_END_NOCRIT_, QS_EQC_, QS_OBJ_, QS_QF_ACTIVE_POST_FIFO, QS_TIME_, QS_U8_, and QEvent::sig.