From e6f4096f2c0e6eb0a3379631b04410d6897a2102 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Sat, 4 Jul 2020 03:39:52 -0700 Subject: [PATCH] no class is derived from container --- src/cnotificationqueue.h | 27 +++++++++++++++++++-------- src/cpacketqueue.h | 39 ++++++++++++++++++++++++++++----------- src/cwiresxcmdqueue.h | 20 ++++++++++++++------ src/cwiresxpacketqueue.h | 20 ++++++++++++++------ 4 files changed, 75 insertions(+), 31 deletions(-) diff --git a/src/cnotificationqueue.h b/src/cnotificationqueue.h index 6e13980..533a47a 100644 --- a/src/cnotificationqueue.h +++ b/src/cnotificationqueue.h @@ -4,6 +4,7 @@ // // Created by Jean-Luc on 05/12/2015. // Copyright © 2015 Jean-Luc. All rights reserved. +// Copyright © 2020 Thomas A. Early, N7TAE // // ---------------------------------------------------------------------------- // This file is part of xlxd. @@ -27,6 +28,9 @@ #ifndef cnotificationqueue_h #define cnotificationqueue_h +#include +#include + #include "cnotification.h" @@ -35,22 +39,29 @@ //////////////////////////////////////////////////////////////////////////////////////// // class -class CNotificationQueue : public std::queue +class CNotificationQueue { public: // constructor - CNotificationQueue() {}; - + CNotificationQueue() {} + // destructor - ~CNotificationQueue() {}; - + ~CNotificationQueue() {} + // lock - void Lock() { m_Mutex.lock(); } - void Unlock() { m_Mutex.unlock(); } - + void Lock() { m_Mutex.lock(); } + void Unlock() { m_Mutex.unlock(); } + + // pass thru + CNotification front() { return queue.front(); } + void pop() { queue.pop(); } + void push(CNotification note) { queue.push(note); } + bool empty() const { return queue.empty(); } + protected: // data std::mutex m_Mutex; + std::queue queue; }; //////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/cpacketqueue.h b/src/cpacketqueue.h index 7f6a217..5e2bbb5 100644 --- a/src/cpacketqueue.h +++ b/src/cpacketqueue.h @@ -4,6 +4,7 @@ // // Created by Jean-Luc Deltombe (LX3JL) on 02/11/2015. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. +// Copyright © 2020 Thomas A. Early, N7TAE // // ---------------------------------------------------------------------------- // This file is part of xlxd. @@ -19,7 +20,7 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with Foobar. If not, see . +// along with Foobar. If not, see . // ---------------------------------------------------------------------------- #ifndef cpacketqueue_h @@ -35,27 +36,43 @@ class CClient; -class CPacketQueue : public std::queue +class CPacketQueue { public: // constructor - CPacketQueue() {}; - + CPacketQueue() {} + // destructor - ~CPacketQueue() {}; - + ~CPacketQueue() + { + Lock(); + while (! queue.empty()) + { + delete queue.front(); + queue.pop(); + } + Unlock(); + } + // lock - void Lock() { m_Mutex.lock(); } - void Unlock() { m_Mutex.unlock(); } - + void Lock() { m_Mutex.lock(); } + void Unlock() { m_Mutex.unlock(); } + + // pass thru + CPacket *front() { return queue.front(); } + void pop() { queue.pop(); } + void push(CPacket *packet) { queue.push(packet); } + bool empty() const { return queue.empty(); } + protected: // status bool m_bOpen; uint16 m_uiStreamId; std::mutex m_Mutex; - + // owner - CClient *m_Client; + CClient *m_Client; + std::queue queue; }; //////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/cwiresxcmdqueue.h b/src/cwiresxcmdqueue.h index ae40a87..7567d30 100644 --- a/src/cwiresxcmdqueue.h +++ b/src/cwiresxcmdqueue.h @@ -4,6 +4,7 @@ // // Created by Jean-Luc Deltombe (LX3JL) on 09/10/2019. // Copyright © 2019 Jean-Luc Deltombe (LX3JL). All rights reserved. +// Copyright © 2020 Thomas A. Early, N7TAE // // ---------------------------------------------------------------------------- // This file is part of xlxd. @@ -33,22 +34,29 @@ //////////////////////////////////////////////////////////////////////////////////////// // class -class CWiresxCmdQueue : public std::queue +class CWiresxCmdQueue { public: // constructor - CWiresxCmdQueue() {}; - + CWiresxCmdQueue() {} + // destructor - ~CWiresxCmdQueue() {}; - + ~CWiresxCmdQueue() {} + // lock void Lock() { m_Mutex.lock(); } void Unlock() { m_Mutex.unlock(); } - + + // pass thru + CWiresxCmd front() { return queue.front(); } + void pop() { queue.pop(); } + void push(CWiresxCmd cmd) { queue.push(cmd); } + bool empty() const { return queue.empty(); } + protected: // status std::mutex m_Mutex; + std::queue queue; }; //////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/cwiresxpacketqueue.h b/src/cwiresxpacketqueue.h index 415a504..95afc04 100644 --- a/src/cwiresxpacketqueue.h +++ b/src/cwiresxpacketqueue.h @@ -4,6 +4,7 @@ // // Created by Jean-Luc Deltombe (LX3JL) on 09/10/2019. // Copyright © 2019 Jean-Luc Deltombe (LX3JL). All rights reserved. +// Copyright © 2020 Thomas A. Early, N7TAE // // ---------------------------------------------------------------------------- // This file is part of xlxd. @@ -32,22 +33,29 @@ //////////////////////////////////////////////////////////////////////////////////////// // class -class CWiresxPacketQueue : public std::queue +class CWiresxPacketQueue { public: // constructor - CWiresxPacketQueue() {}; - + CWiresxPacketQueue() {} + // destructor - ~CWiresxPacketQueue() {}; - + ~CWiresxPacketQueue() {} + // lock void Lock() { m_Mutex.lock(); } void Unlock() { m_Mutex.unlock(); } - + + // pass thru + CWiresxPacket front() { return queue.front(); } + void pop() { queue.pop(); } + void push(CWiresxPacket packet) { queue.push(packet); } + bool empty() const { return queue.empty(); } + protected: // status std::mutex m_Mutex; + std::queue queue; }; ////////////////////////////////////////////////////////////////////////////////////////