From 4515dd94eaf94ec752a007c2b8d11ac70f6527ec Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 10 May 2018 13:21:01 -0500 Subject: [PATCH] Use blocking queue for RRC measurement fixes #193 --- lib/include/srslte/common/block_queue.h | 4 ++++ srsue/hdr/upper/rrc.h | 2 +- srsue/src/upper/rrc.cc | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/include/srslte/common/block_queue.h b/lib/include/srslte/common/block_queue.h index b04a91985..b481022a8 100644 --- a/lib/include/srslte/common/block_queue.h +++ b/lib/include/srslte/common/block_queue.h @@ -86,6 +86,10 @@ public: while (try_pop(item)); } + size_t size() { + return q.size(); + } + private: std::queue q; pthread_mutex_t mutex; diff --git a/srsue/hdr/upper/rrc.h b/srsue/hdr/upper/rrc.h index e59537e2f..a381940ec 100644 --- a/srsue/hdr/upper/rrc.h +++ b/srsue/hdr/upper/rrc.h @@ -547,7 +547,7 @@ private: void process_phy_meas(); void process_new_phy_meas(phy_meas_t meas); - std::queue phy_meas_q; + srslte::block_queue phy_meas_q; // Cell selection/reselection functions/variables typedef struct { diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index 5dfa1b48c..eebbd38b8 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -534,10 +534,10 @@ void rrc::new_phy_meas(float rsrp, float rsrq, uint32_t tti, int earfcn_i, int p /* Processes all pending PHY measurements in queue. Must be called from a mutexed function */ void rrc::process_phy_meas() { - while(!phy_meas_q.empty()) { + phy_meas_t m; + while(phy_meas_q.try_pop(&m)) { rrc_log->debug("MEAS: Processing measurement. %lu measurements in queue\n", phy_meas_q.size()); - process_new_phy_meas(phy_meas_q.front()); - phy_meas_q.pop(); + process_new_phy_meas(m); } }