diff --git a/lib/include/srsran/adt/circular_map.h b/lib/include/srsran/adt/circular_map.h index 1ab4534f3..ce6500112 100644 --- a/lib/include/srsran/adt/circular_map.h +++ b/lib/include/srsran/adt/circular_map.h @@ -28,9 +28,20 @@ class static_circular_map using obj_t = std::pair; public: + using key_type = K; + using mapped_type = T; + using value_type = std::pair; + using difference_type = std::ptrdiff_t; + class iterator { public: + using iterator_category = std::forward_iterator_tag; + using value_type = std::pair; + using difference_type = std::ptrdiff_t; + using pointer = value_type*; + using reference = value_type&; + iterator() = default; iterator(static_circular_map* map, size_t idx_) : ptr(map), idx(idx_) { diff --git a/srsenb/hdr/stack/mac/sched.h b/srsenb/hdr/stack/mac/sched.h index 0a6977f1b..16cc2541f 100644 --- a/srsenb/hdr/stack/mac/sched.h +++ b/srsenb/hdr/stack/mac/sched.h @@ -15,11 +15,11 @@ #include "sched_grid.h" #include "sched_ue.h" +#include "srsenb/hdr/common/common_enb.h" #include "srsran/interfaces/sched_interface.h" #include #include #include -#include namespace srsenb { @@ -91,7 +91,7 @@ protected: sched_args_t sched_cfg = {}; std::vector sched_cell_params; - std::map > ue_db; + rnti_map_t > ue_db; // independent schedulers for each carrier std::vector > carrier_schedulers; diff --git a/srsenb/hdr/stack/mac/sched_carrier.h b/srsenb/hdr/stack/mac/sched_carrier.h index 6fada4517..3ffc51f27 100644 --- a/srsenb/hdr/stack/mac/sched_carrier.h +++ b/srsenb/hdr/stack/mac/sched_carrier.h @@ -26,10 +26,10 @@ class ra_sched; class sched::carrier_sched { public: - explicit carrier_sched(rrc_interface_mac* rrc_, - std::map >* ue_db_, - uint32_t enb_cc_idx_, - sched_result_ringbuffer* sched_results_); + explicit carrier_sched(rrc_interface_mac* rrc_, + sched_ue_list* ue_db_, + uint32_t enb_cc_idx_, + sched_result_ringbuffer* sched_results_); ~carrier_sched(); void reset(); void carrier_cfg(const sched_cell_params_t& sched_params_); @@ -51,11 +51,11 @@ private: sf_sched* get_sf_sched(srsran::tti_point tti_rx); // args - const sched_cell_params_t* cc_cfg = nullptr; - srslog::basic_logger& logger; - rrc_interface_mac* rrc = nullptr; - std::map >* ue_db = nullptr; - const uint32_t enb_cc_idx; + const sched_cell_params_t* cc_cfg = nullptr; + srslog::basic_logger& logger; + rrc_interface_mac* rrc = nullptr; + sched_ue_list* ue_db = nullptr; + const uint32_t enb_cc_idx; // Subframe scheduling logic srsran::circular_array sf_scheds; diff --git a/srsenb/hdr/stack/mac/sched_ue.h b/srsenb/hdr/stack/mac/sched_ue.h index 72d985fa0..91b31e551 100644 --- a/srsenb/hdr/stack/mac/sched_ue.h +++ b/srsenb/hdr/stack/mac/sched_ue.h @@ -14,15 +14,14 @@ #define SRSENB_SCHEDULER_UE_H #include "sched_common.h" -#include "srsran/srslog/srslog.h" -#include -#include - #include "sched_ue_ctrl/sched_lch.h" #include "sched_ue_ctrl/sched_ue_cell.h" #include "sched_ue_ctrl/tpc.h" +#include "srsenb/hdr/common/common_enb.h" +#include "srsran/srslog/srslog.h" #include -#include +#include +#include namespace srsenb { @@ -211,7 +210,7 @@ private: std::vector cells; ///< List of eNB cells that may be configured/activated/deactivated for the UE }; -using sched_ue_list = std::map >; +using sched_ue_list = rnti_map_t >; } // namespace srsenb diff --git a/srsenb/src/stack/mac/sched.cc b/srsenb/src/stack/mac/sched.cc index 48e1724a0..8156adfab 100644 --- a/srsenb/src/stack/mac/sched.cc +++ b/srsenb/src/stack/mac/sched.cc @@ -107,14 +107,14 @@ int sched::ue_cfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg) // Add new user case std::unique_ptr ue{new sched_ue(rnti, sched_cell_params, ue_cfg)}; std::lock_guard lock(sched_mutex); - ue_db.insert(std::make_pair(rnti, std::move(ue))); + ue_db.insert(rnti, std::move(ue)); return SRSRAN_SUCCESS; } int sched::ue_rem(uint16_t rnti) { std::lock_guard lock(sched_mutex); - if (ue_db.count(rnti) > 0) { + if (ue_db.contains(rnti)) { ue_db.erase(rnti); } else { Error("User rnti=0x%x not found", rnti); diff --git a/srsenb/src/stack/mac/schedulers/sched_time_pf.cc b/srsenb/src/stack/mac/schedulers/sched_time_pf.cc index 539c51980..11a0f8aab 100644 --- a/srsenb/src/stack/mac/schedulers/sched_time_pf.cc +++ b/srsenb/src/stack/mac/schedulers/sched_time_pf.cc @@ -24,11 +24,11 @@ sched_time_pf::sched_time_pf(const sched_cell_params_t& cell_params_, const sche fairness_coeff = std::stof(sched_args.sched_policy_args); } - std::vector dl_storage; + std::vector dl_storage; dl_storage.reserve(SRSENB_MAX_UES); dl_queue = ue_dl_queue_t(ue_dl_prio_compare{}, std::move(dl_storage)); - std::vector ul_storage; + std::vector ul_storage; ul_storage.reserve(SRSENB_MAX_UES); ul_queue = ue_ul_queue_t(ue_ul_prio_compare{}, std::move(ul_storage)); } @@ -38,7 +38,7 @@ void sched_time_pf::new_tti(sched_ue_list& ue_db, sf_sched* tti_sched) current_tti_rx = tti_point{tti_sched->get_tti_rx()}; // remove deleted users from history for (auto it = ue_history_db.begin(); it != ue_history_db.end();) { - if (not ue_db.count(it->first)) { + if (not ue_db.contains(it->first)) { it = ue_history_db.erase(it); } else { ++it;