QP/C  7.0.1
Real-Time Embedded Framework
qequeue.h
Go to the documentation of this file.
1/*============================================================================
2* QP/C Real-Time Embedded Framework (RTEF)
3* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
4*
5* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
6*
7* This software is dual-licensed under the terms of the open source GNU
8* General Public License version 3 (or any later version), or alternatively,
9* under the terms of one of the closed source Quantum Leaps commercial
10* licenses.
11*
12* The terms of the open source GNU General Public License version 3
13* can be found at: <www.gnu.org/licenses/gpl-3.0>
14*
15* The terms of the closed source Quantum Leaps commercial licenses
16* can be found at: <www.state-machine.com/licensing>
17*
18* Redistributions in source code must retain this top-level comment block.
19* Plagiarizing this software to sidestep the license obligations is illegal.
20*
21* Contact information:
22* <www.state-machine.com>
23* <info@state-machine.com>
24============================================================================*/
40#ifndef QEQUEUE_H
41#define QEQUEUE_H
42
43#ifndef QF_EQUEUE_CTR_SIZE
44
53 #define QF_EQUEUE_CTR_SIZE 1U
54#endif
55#if (QF_EQUEUE_CTR_SIZE == 1U)
56
63 typedef uint8_t QEQueueCtr;
64#elif (QF_EQUEUE_CTR_SIZE == 2U)
65 typedef uint16_t QEQueueCtr;
66#elif (QF_EQUEUE_CTR_SIZE == 4U)
67 typedef uint32_t QEQueueCtr;
68#else
69 #error "QF_EQUEUE_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U"
70#endif
71
72/*==========================================================================*/
73
119typedef struct QEQueue {
131 QEvt const * volatile frontEvt;
132
134 QEvt const **ring;
135
138
140 QEQueueCtr volatile head;
141
143 QEQueueCtr volatile tail;
144
147
155} QEQueue;
156
157/* public class operations */
158
178void QEQueue_init(QEQueue * const me,
179 QEvt const * * const qSto, uint_fast16_t const qLen);
180
206bool QEQueue_post(QEQueue * const me, QEvt const * const e,
207 uint_fast16_t const margin, uint_fast8_t const qs_id);
208
233void QEQueue_postLIFO(QEQueue * const me, QEvt const * const e,
234 uint_fast8_t const qs_id);
235
256QEvt const *QEQueue_get(QEQueue * const me, uint_fast8_t const qs_id);
257
271static inline QEQueueCtr QEQueue_getNFree(QEQueue * const me) {
272 return me->nFree;
273}
274
286static inline QEQueueCtr QEQueue_getNMin(QEQueue * const me) {
287 return me->nMin;
288}
289
303static inline bool QEQueue_isEmpty(QEQueue * const me) {
304 return me->frontEvt == (QEvt *)0;
305}
306
307#endif /* QEQUEUE_H */
static bool QEQueue_isEmpty(QEQueue *const me)
Definition: qequeue.h:303
static QEQueueCtr QEQueue_getNFree(QEQueue *const me)
Definition: qequeue.h:271
uint16_t QEQueueCtr
Definition: qequeue.h:65
static QEQueueCtr QEQueue_getNMin(QEQueue *const me)
Definition: qequeue.h:286
Native QF Event Queue.
Definition: qequeue.h:119
QEQueueCtr volatile tail
Definition: qequeue.h:143
QEvt const *volatile frontEvt
Definition: qequeue.h:131
QEvt const * QEQueue_get(QEQueue *const me, uint_fast8_t const qs_id)
Definition: qf_qeq.c:184
QEQueueCtr volatile head
Definition: qequeue.h:140
QEQueueCtr end
Definition: qequeue.h:137
QEvt const ** ring
Definition: qequeue.h:134
QEQueueCtr nMin
Definition: qequeue.h:154
QEQueueCtr volatile nFree
Definition: qequeue.h:146
bool QEQueue_post(QEQueue *const me, QEvt const *const e, uint_fast16_t const margin, uint_fast8_t const qs_id)
Definition: qf_qeq.c:61
void QEQueue_postLIFO(QEQueue *const me, QEvt const *const e, uint_fast8_t const qs_id)
Definition: qf_qeq.c:137
void QEQueue_init(QEQueue *const me, QEvt const **const qSto, uint_fast16_t const qLen)
Definition: qf_qeq.c:46
Event class.
Definition: qep.h:121