|
QP/C++
|
00001 00002 // Product: QF/C++, platform-independent event queue interface. 00003 // Last Updated for Version: 4.2.00 00004 // Date of the Last Update: Jul 05, 2011 00005 // 00006 // Q u a n t u m L e a P s 00007 // --------------------------- 00008 // innovating embedded systems 00009 // 00010 // Copyright (C) 2002-2011 Quantum Leaps, LLC. All rights reserved. 00011 // 00012 // This software may be distributed and modified under the terms of the GNU 00013 // General Public License version 2 (GPL) as published by the Free Software 00014 // Foundation and appearing in the file GPL.TXT included in the packaging of 00015 // this file. Please note that GPL Section 2[b] requires that all works based 00016 // on this software must also be made publicly available under the terms of 00017 // the GPL ("Copyleft"). 00018 // 00019 // Alternatively, this software may be distributed and modified under the 00020 // terms of Quantum Leaps commercial licenses, which expressly supersede 00021 // the GPL and are specifically designed for licensees interested in 00022 // retaining the proprietary status of their code. 00023 // 00024 // Contact information: 00025 // Quantum Leaps Web site: http://www.quantum-leaps.com 00026 // e-mail: info@quantum-leaps.com 00028 #ifndef qequeue_h 00029 #define qequeue_h 00030 00040 00041 #ifdef Q_USE_NAMESPACE 00042 namespace QP { 00043 #endif 00044 00045 #ifndef QF_EQUEUE_CTR_SIZE 00046 00054 #define QF_EQUEUE_CTR_SIZE 1 00055 #endif 00056 #if (QF_EQUEUE_CTR_SIZE == 1) 00057 00063 typedef uint8_t QEQueueCtr; 00064 #elif (QF_EQUEUE_CTR_SIZE == 2) 00065 typedef uint16_t QEQueueCtr; 00066 #elif (QF_EQUEUE_CTR_SIZE == 4) 00067 typedef uint32_t QEQueueCtr; 00068 #else 00069 #error "QF_EQUEUE_CTR_SIZE defined incorrectly, expected 1, 2, or 4" 00070 #endif 00071 00072 00114 class QEQueue { 00115 private: 00116 00127 QEvent const *m_frontEvt; 00128 00130 QEvent const **m_ring; 00131 00134 QEQueueCtr m_end; 00135 00137 QEQueueCtr m_head; 00138 00140 QEQueueCtr m_tail; 00141 00143 QEQueueCtr m_nFree; 00144 00150 QEQueueCtr m_nMin; 00151 00152 public: 00153 00162 void init(QEvent const *qSto[], QEQueueCtr qLen); 00163 00173 void postFIFO(QEvent const *e); 00174 00184 void postLIFO(QEvent const *e); 00185 00197 QEvent const *get(void); 00198 00209 QEQueueCtr getNFree(void) const { 00210 return m_nFree; 00211 } 00212 00213 private: 00214 friend class QF; 00215 friend class QActive; 00216 }; 00217 00218 #ifdef Q_USE_NAMESPACE 00219 } // namespace QP 00220 #endif 00221 00222 #endif // qequeue_h 00223
1.7.5.1