QP/C  6.5.1
qf_qeq.c File Reference

QEQueue implementation (QP native thread-safe queue) More...

#include "qf_port.h"
#include "qf_pkg.h"
#include "qassert.h"
#include "qs_port.h"
Include dependency graph for qf_qeq.c:

Go to the source code of this file.

Functions

void QEQueue_init (QEQueue *const me, QEvt const *qSto[], uint_fast16_t const qLen)
 Initialize the native QF event queue. More...
 
bool QEQueue_post (QEQueue *const me, QEvt const *const e, uint_fast16_t const margin)
 Post an event to the "raw" thread-safe event queue (FIFO). More...
 
void QEQueue_postLIFO (QEQueue *const me, QEvt const *const e)
 Post an event to the "raw" thread-safe event queue (LIFO). More...
 
QEvt const * QEQueue_get (QEQueue *const me)
 Obtain an event from the "raw" thread-safe queue. More...
 

Detailed Description

QEQueue implementation (QP native thread-safe queue)

Definition in file qf_qeq.c.

Function Documentation

◆ QEQueue_init()

void QEQueue_init ( QEQueue *const  me,
QEvt const *  qSto[],
uint_fast16_t const  qLen 
)

Initialize the native QF event queue.

Description
Initialize the event queue by giving it the storage for the ring buffer.
Parameters
[in,out]mepointer (see Object Orientation)
[in]qStoan array of pointers to QEvt to sereve as the ring buffer for the event queue
[in]qLenthe length of the qSto[] buffer (in QEvt pointers)
Note
The actual capacity of the queue is qLen + 1, because of the extra location forntEvt.
This function is also used to initialize the event queues of active objects in the built-int QV and QK kernels, as well as other QP ports to OSes/RTOSes that do provide a suitable message queue.

Definition at line 71 of file qf_qeq.c.

◆ QEQueue_post()

bool QEQueue_post ( QEQueue *const  me,
QEvt const *const  e,
uint_fast16_t const  margin 
)

Post an event to the "raw" thread-safe event queue (FIFO).

Note
this function is used for the "raw" thread-safe queues and NOT for the queues of active objects.
Description
Post an event to the "raw" thread-safe event queue using the First-In-First-Out (FIFO) order.
Parameters
[in,out]mepointer (see Object Orientation)
[in]epointer to the event to be posted to the queue
[in]marginnumber of required free slots in the queue after posting the event. The special value QF_NO_MARGIN means that this function will assert if posting
Note
The QF_NO_MARGIN value of the margin parameter is special and denotes situation when the post() operation is assumed to succeed (event delivery guarantee). An assertion fires, when the event cannot be delivered in this case.
Returns
'true' (success) when the posting succeeded with the provided margin and 'false' (failure) when the posting fails.
Note
This function can be called from any task context or ISR context.
See also
QEQueue_postLIFO(), QEQueue_get()
Note
assert if event cannot be posted and dropping events is not acceptable

Definition at line 114 of file qf_qeq.c.

◆ QEQueue_postLIFO()

void QEQueue_postLIFO ( QEQueue *const  me,
QEvt const *const  e 
)

Post an event to the "raw" thread-safe event queue (LIFO).

Description
Post an event to the "raw" thread-safe event queue using the Last-In-First-Out (LIFO) order.
Parameters
[in,out]mepointer (see Object Orientation)
[in]epointer to the event to be posted to the queue
Attention
The LIFO policy should be used only with great caution, because it alters the order of events in the queue.
Note
This function can be called from any task context or ISR context.
this function is used for the "raw" thread-safe queues and not for the queues of active objects.
See also
QEQueue_post(), QEQueue_get(), QActive_defer()
Precondition
the queue must be able to accept the event (cannot overflow)

Definition at line 214 of file qf_qeq.c.

◆ QEQueue_get()

QEvt const* QEQueue_get ( QEQueue *const  me)

Obtain an event from the "raw" thread-safe queue.

Description
Retrieves an event from the front of the "raw" thread-safe queue and returns a pointer to this event to the caller.
Parameters
[in,out]mepointer (see Object Orientation)
Returns
pointer to event at the front of the queue, if the queue is not empty and NULL if the queue is empty.
Note
this function is used for the "raw" thread-safe queues and not for the queues of active objects.
See also
QEQueue_post(), QEQueue_postLIFO(), QActive_recall()

Definition at line 279 of file qf_qeq.c.