QP/C++  8.0.0
Real-Time Embedded Framework
Loading...
Searching...
No Matches
qequeue.hpp
Go to the documentation of this file.
1//$file${include::qequeue.hpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2//
3// Model: qpcpp.qm
4// File: ${include::qequeue.hpp}
5//
6// This code has been generated by QM 7.0.0 <www.state-machine.com/qm>.
7// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
8//
9// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
10//
11// Q u a n t u m L e a P s
12// ------------------------
13// Modern Embedded Software
14//
15// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
16//
17// The QP/C++ software is dual-licensed under the terms of the open-source
18// GNU General Public License (GPL) or under the terms of one of the closed-
19// source Quantum Leaps commercial licenses.
20//
21// Redistributions in source code must retain this top-level comment block.
22// Plagiarizing this software to sidestep the license obligations is illegal.
23//
24// NOTE:
25// The GPL does NOT permit the incorporation of this code into proprietary
26// programs. Please contact Quantum Leaps for commercial licensing options,
27// which expressly supersede the GPL and are designed explicitly for
28// closed-source distribution.
29//
30// Quantum Leaps contact information:
31// <www.state-machine.com/licensing>
32// <info@state-machine.com>
33//
34//$endhead${include::qequeue.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35#ifndef QEQUEUE_HPP_
36#define QEQUEUE_HPP_
37
38#ifndef QF_EQUEUE_CTR_SIZE
39 #define QF_EQUEUE_CTR_SIZE 1U
40#endif
41
42namespace QP {
43
44#if (QF_EQUEUE_CTR_SIZE == 1U)
45 using QEQueueCtr = std::uint8_t;
46#elif (QF_EQUEUE_CTR_SIZE == 2U)
47 using QEQueueCtr = std::uint16_t;
48#else
49 #error "QF_EQUEUE_CTR_SIZE defined incorrectly, expected 1U or 2U"
50#endif
51
52class QEvt; // forward declaration
53
54} // namespace QP
55
56//$declare${QF::QEQueue} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
57namespace QP {
58
59//${QF::QEQueue} .............................................................
60class QEQueue {
61private:
62 QEvt const * volatile m_frontEvt;
63 QEvt const * * m_ring;
68
69#ifndef Q_UNSAFE
70 std::uintptr_t m_frontEvt_dis;
71#endif // ndef Q_UNSAFE
72
73#ifndef Q_UNSAFE
75#endif // ndef Q_UNSAFE
76
77#ifndef Q_UNSAFE
79#endif // ndef Q_UNSAFE
80
81#ifndef Q_UNSAFE
83#endif // ndef Q_UNSAFE
85
86 // friends...
87 friend class QActive;
88 friend class QTicker;
89 friend class QXMutex;
90 friend class QXThread;
91
92public:
93 QEQueue() noexcept
94 : m_frontEvt(nullptr),
95 m_ring(nullptr),
96 m_end(0U),
97 m_head(0U),
98 m_tail(0U),
99 m_nFree(0U),
100 #ifndef Q_UNSAFE
101 m_frontEvt_dis(static_cast<std::uintptr_t>(~0U)),
102 m_head_dis(static_cast<QEQueueCtr>(~0U)),
103 m_tail_dis(static_cast<QEQueueCtr>(~0U)),
104 m_nFree_dis(static_cast<QEQueueCtr>(~0U)),
105 #endif
106 m_nMin(0U)
107 {}
108 void init(
109 QEvt const * qSto[],
110 std::uint_fast16_t const qLen) noexcept;
111 bool post(
112 QEvt const * const e,
113 std::uint_fast16_t const margin,
114 std::uint_fast8_t const qsId) noexcept;
115 void postLIFO(
116 QEvt const * const e,
117 std::uint_fast8_t const qsId) noexcept;
118 QEvt const * get(std::uint_fast8_t const qsId) noexcept;
119 QEQueueCtr getNFree() const noexcept {
120 return m_nFree;
121 }
122 QEQueueCtr getNMin() const noexcept {
123 #ifndef Q_UNSAFE
124 return m_nMin;
125 #else
126 return 0U;
127 #endif
128 }
129 bool isEmpty() const noexcept {
130 return m_frontEvt == nullptr;
131 }
132
133private:
134 QEQueue(QEQueue const & other) = delete;
135 QEQueue & operator=(QEQueue const & other) = delete;
136}; // class QEQueue
137
138} // namespace QP
139//$enddecl${QF::QEQueue} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
140
141#endif // QEQUEUE_HPP_
Active object class (based on the QHsm implementation strategy)
Definition qp.hpp:699
Native QP event queue.
Definition qequeue.hpp:60
QEQueueCtr m_nFree_dis
Definition qequeue.hpp:82
QEQueueCtr m_tail_dis
Definition qequeue.hpp:78
QEQueueCtr volatile m_nFree
Definition qequeue.hpp:67
QEQueue() noexcept
Definition qequeue.hpp:93
QEQueueCtr m_head_dis
Definition qequeue.hpp:74
QEvt const * get(std::uint_fast8_t const qsId) noexcept
Definition qf_qeq.cpp:288
QEQueue & operator=(QEQueue const &other)=delete
void init(QEvt const *qSto[], std::uint_fast16_t const qLen) noexcept
Definition qf_qeq.cpp:63
bool isEmpty() const noexcept
Definition qequeue.hpp:129
QEQueueCtr volatile m_tail
Definition qequeue.hpp:66
QEvt const ** m_ring
Definition qequeue.hpp:63
QEQueueCtr m_nMin
Definition qequeue.hpp:84
bool post(QEvt const *const e, std::uint_fast16_t const margin, std::uint_fast8_t const qsId) noexcept
Definition qf_qeq.cpp:97
QEQueueCtr getNFree() const noexcept
Definition qequeue.hpp:119
QEQueueCtr volatile m_head
Definition qequeue.hpp:65
QEQueue(QEQueue const &other)=delete
QEQueueCtr getNMin() const noexcept
Definition qequeue.hpp:122
QEvt const *volatile m_frontEvt
Definition qequeue.hpp:62
QEQueueCtr m_end
Definition qequeue.hpp:64
std::uintptr_t m_frontEvt_dis
Definition qequeue.hpp:70
void postLIFO(QEvt const *const e, std::uint_fast8_t const qsId) noexcept
Definition qf_qeq.cpp:206
Event class.
Definition qp.hpp:131
"Ticker" Active Object class
Definition qp.hpp:1014
Blocking Mutex of the QXK preemptive kernel.
eXtended (blocking) thread of the QXK preemptive kernel
QP/C++ framework.
Definition qequeue.hpp:42
std::uint16_t QEQueueCtr
Definition qequeue.hpp:47