QP/C 6.9.1
qequeue.h
Go to the documentation of this file.
1 
40 #ifndef QEQUEUE_H
41 #define QEQUEUE_H
42 
54 #ifndef QF_EQUEUE_CTR_SIZE
55 
65  #define QF_EQUEUE_CTR_SIZE 1U
66 #endif
67 #if (QF_EQUEUE_CTR_SIZE == 1U)
68 
77 #elif (QF_EQUEUE_CTR_SIZE == 2U)
78  typedef uint16_t QEQueueCtr;
79 #elif (QF_EQUEUE_CTR_SIZE == 4U)
80  typedef uint32_t QEQueueCtr;
81 #else
82  #error "QF_EQUEUE_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U"
83 #endif
84 
85 /****************************************************************************/
130 typedef struct QEQueue {
143  QEvt const * volatile frontEvt;
144 
146  QEvt const **ring;
147 
150 
152  QEQueueCtr volatile head;
153 
155  QEQueueCtr volatile tail;
156 
158  QEQueueCtr volatile nFree;
159 
168 } QEQueue;
169 
170 /* public class operations */
171 
173 void QEQueue_init(QEQueue * const me,
174  QEvt const * * const qSto, uint_fast16_t const qLen);
175 
177 bool QEQueue_post(QEQueue * const me, QEvt const * const e,
178  uint_fast16_t const margin, uint_fast8_t const qs_id);
179 
181 void QEQueue_postLIFO(QEQueue * const me, QEvt const * const e,
182  uint_fast8_t const qs_id);
183 
185 QEvt const *QEQueue_get(QEQueue * const me, uint_fast8_t const qs_id);
186 
201 #define QEQueue_getNFree(me_) ((me_)->nFree)
202 
215 #define QEQueue_getNMin(me_) ((me_)->nMin)
216 
231 #define QEQueue_isEmpty(me_) ((me_)->frontEvt == (QEvt *)0)
232 
233 #endif /* QEQUEUE_H */
234 
uint8_t
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: 16bit/stdint.h:29
QEQueue_get
QEvt const * QEQueue_get(QEQueue *const me, uint_fast8_t const qs_id)
Obtain an event from the "raw" thread-safe queue.
Definition: qf_qeq.c:284
QEQueue::tail
QEQueueCtr volatile tail
offset of where next event will be extracted from the buffer.
Definition: qequeue.h:155
uint16_t
unsigned int uint16_t
exact-width 16-bit unsigned int
Definition: 16bit/stdint.h:30
QEQueue
Native QF Event Queue.
Definition: qequeue.h:130
QEQueue::nMin
QEQueueCtr nMin
minimum number of free events ever in the ring buffer.
Definition: qequeue.h:167
uint_fast8_t
unsigned int uint_fast8_t
fast at-least 8-bit unsigned int
Definition: 16bit/stdint.h:36
QEQueueCtr
uint8_t QEQueueCtr
The data type to store the ring-buffer counters based on the macro QF_EQUEUE_CTR_SIZE.
Definition: qequeue.h:76
QEQueue_post
bool QEQueue_post(QEQueue *const me, QEvt const *const e, uint_fast16_t const margin, uint_fast8_t const qs_id)
Post an event to the "raw" thread-safe event queue (FIFO).
Definition: qf_qeq.c:115
QEvt
Event class.
Definition: qep.h:151
QEQueue_init
void QEQueue_init(QEQueue *const me, QEvt const **const qSto, uint_fast16_t const qLen)
Initialize the native QF event queue.
Definition: qf_qeq.c:72
QEQueue::ring
QEvt const ** ring
pointer to the start of the ring buffer.
Definition: qequeue.h:146
QEQueue::end
QEQueueCtr end
offset of the end of the ring buffer from the start of the buffer.
Definition: qequeue.h:149
QEQueue_postLIFO
void QEQueue_postLIFO(QEQueue *const me, QEvt const *const e, uint_fast8_t const qs_id)
Post an event to the "raw" thread-safe event queue (LIFO).
Definition: qf_qeq.c:215
QEQueue::nFree
QEQueueCtr volatile nFree
number of free events in the ring buffer.
Definition: qequeue.h:158
QEQueue::head
QEQueueCtr volatile head
offset to where next event will be inserted into the buffer.
Definition: qequeue.h:152
QEQueue::frontEvt
QEvt const *volatile frontEvt
pointer to event at the front of the queue.
Definition: qequeue.h:143
uint32_t
unsigned long int uint32_t
exact-width 32-bit unsigned int
Definition: 16bit/stdint.h:31
uint_fast16_t
unsigned int uint_fast16_t
fast at-least 16-bit unsigned int
Definition: 16bit/stdint.h:38