|
QP/C++
|
00001 00002 // Product: QF/C++ 00003 // Last Updated for Version: 4.5.00 00004 // Date of the Last Update: May 19, 2012 00005 // 00006 // Q u a n t u m L e a P s 00007 // --------------------------- 00008 // innovating embedded systems 00009 // 00010 // Copyright (C) 2002-2012 Quantum Leaps, LLC. All rights reserved. 00011 // 00012 // This program is open source software: you can redistribute it and/or 00013 // modify it under the terms of the GNU General Public License as published 00014 // by the Free Software Foundation, either version 2 of the License, or 00015 // (at your option) any later version. 00016 // 00017 // Alternatively, this program may be distributed and modified under the 00018 // terms of Quantum Leaps commercial licenses, which expressly supersede 00019 // the GNU General Public License and are specifically designed for 00020 // licensees interested in retaining the proprietary status of their code. 00021 // 00022 // This program is distributed in the hope that it will be useful, 00023 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 // GNU General Public License for more details. 00026 // 00027 // You should have received a copy of the GNU General Public License 00028 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00029 // 00030 // Contact information: 00031 // Quantum Leaps Web sites: http://www.quantum-leaps.com 00032 // http://www.state-machine.com 00033 // e-mail: info@quantum-leaps.com 00035 #include "qf_pkg.h" 00036 #include "qassert.h" 00037 00041 00042 QP_BEGIN_ 00043 00044 Q_DEFINE_THIS_MODULE("qf_new") 00045 00046 //............................................................................ 00047 QEvt *QF::new_(QEvtSize const evtSize, enum_t const sig) { 00048 // find the pool id that fits the requested event size ... 00049 uint8_t idx = u8_0; 00050 while (evtSize 00051 > static_cast<QEvtSize>(QF_EPOOL_EVENT_SIZE_(QF_pool_[idx]))) 00052 { 00053 ++idx; 00054 Q_ASSERT(idx < QF_maxPool_); // cannot run out of registered pools 00055 } 00056 00057 QS_CRIT_STAT_ 00058 QS_BEGIN_(QS_QF_NEW, null_void, null_void) 00059 QS_TIME_(); // timestamp 00060 QS_EVS_(evtSize); // the size of the event 00061 QS_SIG_(static_cast<QSignal>(sig)); // the signal of the event 00062 QS_END_() 00063 00064 QEvt *e; 00065 QF_EPOOL_GET_(QF_pool_[idx], e); 00066 Q_ASSERT(e != static_cast<QEvt *>(0));// pool must not run out of events 00067 00068 e->sig = static_cast<QSignal>(sig); // set signal for this event 00069 e->poolId_ = static_cast<uint8_t>(idx + u8_1); // store pool ID in the evt 00070 e->refCtr_ = u8_0; // set the reference counter to 0 00071 00072 return e; 00073 } 00074 00075 QP_END_
1.7.6.1