QP/C  8.0.2
Real-Time Embedded Framework
Loading...
Searching...
No Matches
QEQueue Class Reference

Native QF Event Queue. More...

#include "qequeue.h"

Public Member Functions

void QEQueue_init (QEQueue *const me, struct QEvt const **const qSto, uint_fast16_t const qLen)
 
bool QEQueue_post (QEQueue *const me, struct QEvt const *const e, uint_fast16_t const margin, uint_fast8_t const qsId)
 
void QEQueue_postLIFO (QEQueue *const me, struct QEvt const *const e, uint_fast8_t const qsId)
 
struct QEvt const * QEQueue_get (QEQueue *const me, uint_fast8_t const qsId)
 

Static Public Member Functions

static QEQueueCtr QEQueue_getNFree (QEQueue const *const me)
 
static QEQueueCtr QEQueue_getNMin (QEQueue const *const me)
 
static bool QEQueue_isEmpty (QEQueue const *const me)
 

Private Attributes

struct QEvt const *volatile frontEvt
 Pointer to event at the front of the queue.
 
struct QEvt const ** ring
 Pointer to the start of the ring buffer.
 
QEQueueCtr end
 Offset of the end of the ring buffer from the start of the buffer.
 
QEQueueCtr volatile head
 Offset to where next event will be inserted into the buffer.
 
QEQueueCtr volatile tail
 Offset of where next event will be extracted from the buffer.
 
QEQueueCtr volatile nFree
 Number of free events in the ring buffer.
 
QEQueueCtr nMin
 Minimum number of free events ever in the ring buffer.
 

Detailed Description

Native QF Event Queue.

Details

This class describes the native QF event queue, which can be used as the event queue for active objects, or as a simple "raw" event queue for thread-safe event passing among non-framework entities, such as ISRs, device drivers, or other third-party components.

The native QF event queue is configured by defining the macro QACTIVE_EQUEUE_TYPE as QEQueue in the specific QF port header file.

The QEQueue structure contains only data members for managing an event queue, but does not contain the storage for the queue buffer, which must be provided externally during the queue initialization.

The event queue can store only event pointers, not the whole events. The internal implementation uses the standard ring-buffer plus one external location that optimizes the queue operation for the most frequent case of empty queue.

The QEQueue structure is used with two sets of functions. One set is for the active object event queue, which might need to block the active object task when the event queue is empty and might need to unblock it when events are posted to the queue. The interface for the native active object event queue consists of the following functions: QActive_post(), QActive_postLIFO(), and QActive_get_(). Additionally the function QEQueue_initX() is used to initialize the queue.

The other set of functions, uses QEQueue as a simple "raw" event queue to pass events between entities other than active objects, such as ISRs. The "raw" event queue is not capable of blocking on the get() operation, but is still thread-safe because it uses QF critical section to protect its integrity. The interface for the "raw" thread-safe queue consists of the following functions: QEQueue_post(), QEQueue_postLIFO(), and QEQueue_get(). Additionally the function QEQueue_initX() is used to initialize the queue.

Most event queue operations (both the active object queues and the "raw" queues) internally use the QF critical section. You should be careful not to invoke those operations from other critical sections when nesting of critical sections is not supported.

See also
QEQueue for the description of the data members

Definition at line 49 of file qequeue.h.

Member Function Documentation

◆ QEQueue_init()

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

◆ QEQueue_post()

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

Definition at line 71 of file qf_qeq.c.

◆ QEQueue_postLIFO()

void QEQueue_postLIFO ( QEQueue *const me,
struct QEvt const *const e,
uint_fast8_t const qsId )

Definition at line 153 of file qf_qeq.c.

◆ QEQueue_get()

struct QEvt const * QEQueue_get ( QEQueue *const me,
uint_fast8_t const qsId )

Definition at line 210 of file qf_qeq.c.

◆ QEQueue_getNFree()

static QEQueueCtr QEQueue_getNFree ( QEQueue const *const me)
inlinestatic

Definition at line 80 of file qequeue.h.

◆ QEQueue_getNMin()

static QEQueueCtr QEQueue_getNMin ( QEQueue const *const me)
inlinestatic

Definition at line 85 of file qequeue.h.

◆ QEQueue_isEmpty()

static bool QEQueue_isEmpty ( QEQueue const *const me)
inlinestatic

Definition at line 90 of file qequeue.h.

Member Data Documentation

◆ frontEvt

struct QEvt const* volatile frontEvt
private

Pointer to event at the front of the queue.

Details

All incoming and outgoing events pass through the frontEvt location. When the queue is empty (which is most of the time), the extra frontEvt location allows to bypass the ring buffer altogether, greatly optimizing the performance of the queue. Only bursts of events engage the ring buffer.

The additional role of this attribute is to indicate the empty status of the queue. The queue is empty when frontEvt is NULL.

Definition at line 50 of file qequeue.h.

◆ ring

struct QEvt const* * ring
private

Pointer to the start of the ring buffer.

Definition at line 51 of file qequeue.h.

◆ end

QEQueueCtr end
private

Offset of the end of the ring buffer from the start of the buffer.

Definition at line 52 of file qequeue.h.

◆ head

QEQueueCtr volatile head
private

Offset to where next event will be inserted into the buffer.

Definition at line 53 of file qequeue.h.

◆ tail

QEQueueCtr volatile tail
private

Offset of where next event will be extracted from the buffer.

Definition at line 54 of file qequeue.h.

◆ nFree

QEQueueCtr volatile nFree
private

Number of free events in the ring buffer.

Definition at line 55 of file qequeue.h.

◆ nMin

QEQueueCtr nMin
private

Minimum number of free events ever in the ring buffer.

Details

This attribute remembers the low-watermark of the ring buffer, which provides a valuable information for sizing event queues.

See also
  • QF_getQueueMargin()

Definition at line 56 of file qequeue.h.


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