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

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

@ -184,20 +184,24 @@ public:
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;
++next;
it->~obj_t();
present[it->first] = false;
present[it.idx] = false;
get_obj_(it.idx).~obj_t();
--count;
return next;
}
void clear()
{
for (auto it = begin(); it != end();) {
it = erase(it);
for (size_t i = 0; i < N; ++i) {
if (present[i]) {
present[i] = false;
get_obj_(i).~obj_t();
}
}
count = 0;
}
T& operator[](K id)

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

@ -63,6 +63,7 @@ class cc_used_buffers_map
{
public:
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);
@ -180,11 +181,11 @@ private:
bool process_ce(srsran::sch_subh* subh);
void allocate_ce(srsran::sch_pdu* pdu, uint32_t lcid);
uint32_t phr_counter = 0;
uint32_t dl_cqi_counter = 0;
uint32_t dl_ri_counter = 0;
uint32_t dl_pmi_counter = 0;
mac_ue_metrics_t ue_metrics = {};
rlc_interface_mac* rlc = nullptr;
rrc_interface_mac* rrc = nullptr;
phy_interface_stack_lte* phy = nullptr;
srslog::basic_logger& logger;
sched_interface* sched = nullptr;
srsran::mac_pcap* pcap = nullptr;
srsran::mac_pcap_net* pcap_net = nullptr;
@ -193,11 +194,13 @@ private:
uint32_t last_tti = 0;
uint32_t nof_failures = 0;
srsran::obj_pool_itf<ue_cc_softbuffers>* softbuffer_pool = nullptr;
srsran::bounded_vector<cc_buffer_handler, SRSRAN_MAX_CARRIERS> cc_buffers;
uint32_t phr_counter = 0;
uint32_t dl_cqi_counter = 0;
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;
ta ta_fsm;
@ -207,14 +210,11 @@ private:
srsran::sch_pdu mac_msg_dl, mac_msg_ul;
srsran::mch_pdu mch_mac_msg_dl;
rlc_interface_mac* rlc = nullptr;
rrc_interface_mac* rrc = nullptr;
phy_interface_stack_lte* phy = nullptr;
srslog::basic_logger& logger;
sched_interface* sched = nullptr;
srsran::bounded_vector<cc_buffer_handler, SRSRAN_MAX_CARRIERS> cc_buffers;
// Mutexes
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)
};

@ -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"))
{}
cc_used_buffers_map::~cc_used_buffers_map()
{
clear();
}
bool cc_used_buffers_map::push_pdu(tti_point tti, uint32_t len)
{
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()
{
for (auto& buffer : pdu_map) {
shared_pdu_queue->deallocate(buffer.second);
}
pdu_map.clear();
}

Loading…
Cancel
Save