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

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

Direct event posting is the simplest asynchronous communication method available in QF. The following example illustrates how the Philosopher 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 (Philosopher in this case) must only "know" the recipient (Table) by a generic (QActive *QDPP_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 43 of file qa_fifo.c.

References Q_ASSERT, QACTIVE_EQUEUE_SIGNAL_, QS_aoObj_, QS_BEGIN_NOLOCK_, QS_END_NOLOCK_, QS_EQC_, QS_OBJ_, QS_QF_ACTIVE_POST_FIFO, QS_SIG_, QS_TIME_, and QS_U8_.

Referenced by QF_publish(), and QF_tick().


Generated on Fri Aug 1 14:15:08 2008 for QP/C by  doxygen 1.5.4