adt - fix circular map clear() and erase(it) functions

master
Francisco 4 years ago committed by Francisco Paisana
parent 643c73acee
commit b7d4a72ea1

@ -184,21 +184,25 @@ public:
iterator erase(iterator it) iterator erase(iterator it)
{ {
srsran_assert(it.idx < N, "Iterator out-of-bounds (%zd >= %zd)", it.idx, N); srsran_assert(it.idx < N and it.ptr == this, "Iterator out-of-bounds (%zd >= %zd)", it.idx, N);
iterator next = it; iterator next = it;
++next; ++next;
it->~obj_t(); present[it.idx] = false;
present[it->first] = false; get_obj_(it.idx).~obj_t();
--count; --count;
return next; return next;
} }
void clear() void clear()
{ {
for (auto it = begin(); it != end();) { for (size_t i = 0; i < N; ++i) {
it = erase(it); if (present[i]) {
present[i] = false;
get_obj_(i).~obj_t();
} }
} }
count = 0;
}
T& operator[](K id) T& operator[](K id)
{ {

@ -58,8 +58,8 @@ private:
} pdu_t; } pdu_t;
static_blocking_queue<pdu_t*, DEFAULT_POOL_SIZE> pdu_q;
buffer_pool<pdu_t> pool; buffer_pool<pdu_t> pool;
static_blocking_queue<pdu_t*, DEFAULT_POOL_SIZE> pdu_q;
process_callback* callback; process_callback* callback;
srslog::basic_logger& logger; srslog::basic_logger& logger;

@ -63,6 +63,7 @@ class cc_used_buffers_map
{ {
public: public:
explicit cc_used_buffers_map(srsran::pdu_queue& shared_pdu_queue_); explicit cc_used_buffers_map(srsran::pdu_queue& shared_pdu_queue_);
~cc_used_buffers_map();
uint8_t* request_pdu(tti_point tti, uint32_t len); uint8_t* request_pdu(tti_point tti, uint32_t len);
@ -180,11 +181,11 @@ private:
bool process_ce(srsran::sch_subh* subh); bool process_ce(srsran::sch_subh* subh);
void allocate_ce(srsran::sch_pdu* pdu, uint32_t lcid); void allocate_ce(srsran::sch_pdu* pdu, uint32_t lcid);
uint32_t phr_counter = 0; rlc_interface_mac* rlc = nullptr;
uint32_t dl_cqi_counter = 0; rrc_interface_mac* rrc = nullptr;
uint32_t dl_ri_counter = 0; phy_interface_stack_lte* phy = nullptr;
uint32_t dl_pmi_counter = 0; srslog::basic_logger& logger;
mac_ue_metrics_t ue_metrics = {}; sched_interface* sched = nullptr;
srsran::mac_pcap* pcap = nullptr; srsran::mac_pcap* pcap = nullptr;
srsran::mac_pcap_net* pcap_net = nullptr; srsran::mac_pcap_net* pcap_net = nullptr;
@ -193,11 +194,13 @@ private:
uint32_t last_tti = 0; uint32_t last_tti = 0;
uint32_t nof_failures = 0; uint32_t nof_failures = 0;
srsran::obj_pool_itf<ue_cc_softbuffers>* softbuffer_pool = nullptr; uint32_t phr_counter = 0;
uint32_t dl_cqi_counter = 0;
srsran::bounded_vector<cc_buffer_handler, SRSRAN_MAX_CARRIERS> cc_buffers; uint32_t dl_ri_counter = 0;
uint32_t dl_pmi_counter = 0;
mac_ue_metrics_t ue_metrics = {};
std::mutex rx_buffers_mutex; srsran::obj_pool_itf<ue_cc_softbuffers>* softbuffer_pool = nullptr;
srsran::block_queue<uint32_t> pending_ta_commands; srsran::block_queue<uint32_t> pending_ta_commands;
ta ta_fsm; ta ta_fsm;
@ -207,14 +210,11 @@ private:
srsran::sch_pdu mac_msg_dl, mac_msg_ul; srsran::sch_pdu mac_msg_dl, mac_msg_ul;
srsran::mch_pdu mch_mac_msg_dl; srsran::mch_pdu mch_mac_msg_dl;
rlc_interface_mac* rlc = nullptr; srsran::bounded_vector<cc_buffer_handler, SRSRAN_MAX_CARRIERS> cc_buffers;
rrc_interface_mac* rrc = nullptr;
phy_interface_stack_lte* phy = nullptr;
srslog::basic_logger& logger;
sched_interface* sched = nullptr;
// Mutexes // Mutexes
std::mutex mutex; std::mutex mutex;
std::mutex rx_buffers_mutex;
const uint8_t UL_CC_IDX = 0; ///< Passed to write CC index in PCAP (TODO: use actual CC idx) const uint8_t UL_CC_IDX = 0; ///< Passed to write CC index in PCAP (TODO: use actual CC idx)
}; };

@ -66,6 +66,11 @@ cc_used_buffers_map::cc_used_buffers_map(srsran::pdu_queue& shared_pdu_queue_) :
shared_pdu_queue(&shared_pdu_queue_), logger(&srslog::fetch_basic_logger("MAC")) shared_pdu_queue(&shared_pdu_queue_), logger(&srslog::fetch_basic_logger("MAC"))
{} {}
cc_used_buffers_map::~cc_used_buffers_map()
{
clear();
}
bool cc_used_buffers_map::push_pdu(tti_point tti, uint32_t len) bool cc_used_buffers_map::push_pdu(tti_point tti, uint32_t len)
{ {
if (not has_tti(tti)) { if (not has_tti(tti)) {
@ -135,6 +140,9 @@ bool cc_used_buffers_map::try_deallocate_pdu(tti_point tti)
void cc_used_buffers_map::clear() void cc_used_buffers_map::clear()
{ {
for (auto& buffer : pdu_map) {
shared_pdu_queue->deallocate(buffer.second);
}
pdu_map.clear(); pdu_map.clear();
} }

Loading…
Cancel
Save