From 197fb2c166faf643857dacdd19bfc838175fad53 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Thu, 28 Oct 2021 18:02:57 -0700 Subject: [PATCH] condensed front() and pop() into pop() --- reflector/CodecStream.cpp | 6 ++---- reflector/DCSProtocol.cpp | 3 +-- reflector/DCSProtocol.h | 2 +- reflector/DExtraProtocol.cpp | 3 +-- reflector/DMRMMDVMProtocol.cpp | 3 +-- reflector/DMRPlusProtocol.cpp | 3 +-- reflector/DPlusProtocol.cpp | 3 +-- reflector/G3Protocol.cpp | 3 +-- reflector/PacketQueue.h | 5 ++--- reflector/Reflector.cpp | 3 +-- reflector/ULXProtocol.cpp | 3 +-- reflector/YSFProtocol.cpp | 3 +-- 12 files changed, 14 insertions(+), 26 deletions(-) diff --git a/reflector/CodecStream.cpp b/reflector/CodecStream.cpp index e4f9c29..53c1e80 100644 --- a/reflector/CodecStream.cpp +++ b/reflector/CodecStream.cpp @@ -181,9 +181,8 @@ void CCodecStream::Task(void) // pop the original packet if ( !m_LocalQueue.empty() ) { - auto Packet = m_LocalQueue.front(); + auto Packet = m_LocalQueue.pop(); auto Frame = (CDvFramePacket *)Packet.get(); - m_LocalQueue.pop(); // todo: check the PID // update content with transcoded ambe Frame->SetAmbe(m_uiCodecOut, Ambe); @@ -208,9 +207,8 @@ void CCodecStream::Task(void) while ( !empty() ) { // yes, pop it from queue - auto Packet = front(); + auto Packet = pop(); auto Frame = (CDvFramePacket *)Packet.get(); - pop(); // yes, send to ambed // this assume that thread pushing the Packet diff --git a/reflector/DCSProtocol.cpp b/reflector/DCSProtocol.cpp index bac3fc1..1d7d990 100644 --- a/reflector/DCSProtocol.cpp +++ b/reflector/DCSProtocol.cpp @@ -232,8 +232,7 @@ void CDcsProtocol::HandleQueue(void) while ( !m_Queue.empty() ) { // get the packet - auto packet = m_Queue.front(); - m_Queue.pop(); + auto packet = m_Queue.pop(); // get our sender's id int iModId = g_Reflector.GetModuleIndex(packet->GetModuleId()); diff --git a/reflector/DCSProtocol.h b/reflector/DCSProtocol.h index 6460629..e02e09e 100644 --- a/reflector/DCSProtocol.h +++ b/reflector/DCSProtocol.h @@ -37,7 +37,7 @@ public: ~CDcsStreamCacheItem() {} CDvHeaderPacket m_dvHeader; - uint32_t m_iSeqCounter; + uint32_t m_iSeqCounter; }; class CDcsProtocol : public CProtocol diff --git a/reflector/DExtraProtocol.cpp b/reflector/DExtraProtocol.cpp index 5d3d89f..62f39c6 100644 --- a/reflector/DExtraProtocol.cpp +++ b/reflector/DExtraProtocol.cpp @@ -223,8 +223,7 @@ void CDextraProtocol::HandleQueue(void) while ( !m_Queue.empty() ) { // get the packet - auto packet = m_Queue.front(); - m_Queue.pop(); + auto packet = m_Queue.pop(); // encode it CBuffer buffer; diff --git a/reflector/DMRMMDVMProtocol.cpp b/reflector/DMRMMDVMProtocol.cpp index eefce2c..30bb6fb 100644 --- a/reflector/DMRMMDVMProtocol.cpp +++ b/reflector/DMRMMDVMProtocol.cpp @@ -351,8 +351,7 @@ void CDmrmmdvmProtocol::HandleQueue(void) while ( !m_Queue.empty() ) { // get the packet - auto packet = m_Queue.front(); - m_Queue.pop(); + auto packet = m_Queue.pop(); // get our sender's id int iModId = g_Reflector.GetModuleIndex(packet->GetModuleId()); diff --git a/reflector/DMRPlusProtocol.cpp b/reflector/DMRPlusProtocol.cpp index d04c899..c414f88 100644 --- a/reflector/DMRPlusProtocol.cpp +++ b/reflector/DMRPlusProtocol.cpp @@ -224,8 +224,7 @@ void CDmrplusProtocol::HandleQueue(void) while ( !m_Queue.empty() ) { // get the packet - auto packet = m_Queue.front(); - m_Queue.pop(); + auto packet = m_Queue.pop(); // get our sender's id int iModId = g_Reflector.GetModuleIndex(packet->GetModuleId()); diff --git a/reflector/DPlusProtocol.cpp b/reflector/DPlusProtocol.cpp index c03a793..80bbe2a 100644 --- a/reflector/DPlusProtocol.cpp +++ b/reflector/DPlusProtocol.cpp @@ -238,8 +238,7 @@ void CDplusProtocol::HandleQueue(void) while ( !m_Queue.empty() ) { // get the packet - auto packet = m_Queue.front(); - m_Queue.pop(); + auto packet = m_Queue.pop(); // get our sender's id int iModId = g_Reflector.GetModuleIndex(packet->GetModuleId()); diff --git a/reflector/G3Protocol.cpp b/reflector/G3Protocol.cpp index d93aa7d..cb0b207 100644 --- a/reflector/G3Protocol.cpp +++ b/reflector/G3Protocol.cpp @@ -452,8 +452,7 @@ void CG3Protocol::HandleQueue(void) m_LastKeepaliveTime.start(); // get the packet - auto packet = m_Queue.front(); - m_Queue.pop(); + auto packet = m_Queue.pop(); // encode it CBuffer buffer; diff --git a/reflector/PacketQueue.h b/reflector/PacketQueue.h index 625b62d..38ba786 100644 --- a/reflector/PacketQueue.h +++ b/reflector/PacketQueue.h @@ -39,15 +39,14 @@ public: void Unlock() { m_Mutex.unlock(); } // pass thru - void pop() { queue.pop(); } + std::unique_ptr pop() { auto pack = std::move(queue.front()); queue.pop(); return std::move(pack); } bool empty() const { return queue.empty(); } - std::unique_ptr front() { return std::move(queue.front()); } void push(std::unique_ptr &packet) { queue.push(std::move(packet)); } protected: // status bool m_bOpen; - uint16_t m_uiStreamId; + uint16_t m_uiStreamId; std::mutex m_Mutex; // owner diff --git a/reflector/Reflector.cpp b/reflector/Reflector.cpp index 4d9ca8f..d215ba3 100644 --- a/reflector/Reflector.cpp +++ b/reflector/Reflector.cpp @@ -283,8 +283,7 @@ void CReflector::RouterThread(CPacketStream *streamIn) if ( !streamIn->empty() ) { // get the packet - packet = streamIn->front(); - streamIn->pop(); + packet = streamIn->pop(); } else { diff --git a/reflector/ULXProtocol.cpp b/reflector/ULXProtocol.cpp index fb15288..1265b11 100644 --- a/reflector/ULXProtocol.cpp +++ b/reflector/ULXProtocol.cpp @@ -224,8 +224,7 @@ void CUlxProtocol::HandleQueue(void) while ( !m_Queue.empty() ) { // get the packet - auto packet = m_Queue.front(); - m_Queue.pop(); + auto packet = m_Queue.pop(); // check if origin of packet is local // if not, do not stream it out as it will cause diff --git a/reflector/YSFProtocol.cpp b/reflector/YSFProtocol.cpp index 1ead876..006e10f 100644 --- a/reflector/YSFProtocol.cpp +++ b/reflector/YSFProtocol.cpp @@ -279,8 +279,7 @@ void CYsfProtocol::HandleQueue(void) while ( !m_Queue.empty() ) { // get the packet - auto packet = m_Queue.front(); - m_Queue.pop(); + auto packet = m_Queue.pop(); // get our sender's id int iModId = g_Reflector.GetModuleIndex(packet->GetModuleId());