remove unnecessary sfinae from bounded_vector. Use bounded_vector for UE cc buffers. Set ue cc used buffers remove_pdu method to private

master
Francisco 4 years ago committed by Francisco Paisana
parent 196bf710c0
commit ca7fe1349e

@ -30,19 +30,12 @@ public:
using value_type = T; using value_type = T;
bounded_vector() = default; bounded_vector() = default;
template <typename std::enable_if<std::is_default_constructible<T>::value, int>::type = 0> explicit bounded_vector(size_type N) { append(N); }
explicit bounded_vector(size_type N) bounded_vector(size_type N, const T& val) { append(N, val); }
{
append(N);
}
template <typename U, typename std::enable_if<std::is_constructible<T, const U&>::value, int>::type = 0>
bounded_vector(size_type N, const U& init_val)
{
append(N, T(init_val));
}
bounded_vector(const bounded_vector& other) { append(other.begin(), other.end()); } bounded_vector(const bounded_vector& other) { append(other.begin(), other.end()); }
bounded_vector(bounded_vector&& other) noexcept bounded_vector(bounded_vector&& other) noexcept
{ {
static_assert(std::is_move_constructible<T>::value, "T must be move-constructible");
std::uninitialized_copy(std::make_move_iterator(other.begin()), std::make_move_iterator(other.end()), end()); std::uninitialized_copy(std::make_move_iterator(other.begin()), std::make_move_iterator(other.end()), end());
size_ = other.size(); size_ = other.size();
other.clear(); other.clear();
@ -114,13 +107,13 @@ public:
} }
T& front() { return (*this)[0]; } T& front() { return (*this)[0]; }
const T& front() const { return (*this)[0]; } const T& front() const { return (*this)[0]; }
T* data() { return reinterpret_cast<T*>(&buffer[0]); } T* data() { return &front(); }
const T* data() const { return reinterpret_cast<T*>(&buffer[0]); } const T* data() const { return &front(); }
// Iterators // Iterators
iterator begin() { return reinterpret_cast<iterator>(&buffer[0]); } iterator begin() { return data(); }
iterator end() { return begin() + size_; } iterator end() { return begin() + size_; }
const_iterator begin() const { return reinterpret_cast<const_iterator>(&buffer[0]); } const_iterator begin() const { return data(); }
const_iterator end() const { return begin() + size_; } const_iterator end() const { return begin() + size_; }
// Capacity // Capacity
@ -159,19 +152,22 @@ public:
} }
void push_back(const T& value) void push_back(const T& value)
{ {
static_assert(std::is_copy_constructible<T>::value, "T must be copy-constructible");
size_++; size_++;
assert(size_ <= MAX_N); assert(size_ <= MAX_N);
new (&back()) T(value); new (&back()) T(value);
} }
void push_back(T&& value) void push_back(T&& value)
{ {
static_assert(std::is_move_constructible<T>::value, "T must be move-constructible");
size_++; size_++;
assert(size_ <= MAX_N); assert(size_ <= MAX_N);
new (&back()) T(std::move(value)); new (&back()) T(std::move(value));
} }
template <typename... Args> template <typename... Args>
typename std::enable_if<std::is_constructible<T, Args...>::value>::type emplace_back(Args&&... args) void emplace_back(Args&&... args)
{ {
static_assert(std::is_constructible<T, Args&&...>::value, "Passed arguments to emplace_back are invalid");
size_++; size_++;
assert(size_ <= MAX_N); assert(size_ <= MAX_N);
new (&back()) T(std::forward<Args>(args)...); new (&back()) T(std::forward<Args>(args)...);
@ -182,9 +178,14 @@ public:
back().~T(); back().~T();
size_--; size_--;
} }
typename std::enable_if<std::is_default_constructible<T>::value>::type resize(size_type count) { resize(count, T()); } void resize(size_type count)
{
static_assert(std::is_default_constructible<T>::value, "T must be default constructible");
resize(count, T());
}
void resize(size_type count, const T& value) void resize(size_type count, const T& value)
{ {
static_assert(std::is_copy_constructible<T>::value, "T must be copy constructible");
if (size_ > count) { if (size_ > count) {
destroy(begin() + count, end()); destroy(begin() + count, end());
size_ = count; size_ = count;
@ -215,12 +216,14 @@ private:
} }
void append(size_type N, const T& element) void append(size_type N, const T& element)
{ {
static_assert(std::is_copy_constructible<T>::value, "T must be copy-constructible");
assert(N + size_ <= MAX_N); assert(N + size_ <= MAX_N);
std::uninitialized_fill_n(end(), N, element); std::uninitialized_fill_n(end(), N, element);
size_ += N; size_ += N;
} }
void append(size_type N) void append(size_type N)
{ {
static_assert(std::is_default_constructible<T>::value, "T must be default-constructible");
assert(N + size_ <= MAX_N); assert(N + size_ <= MAX_N);
for (size_type i = size_; i < size_ + N; ++i) { for (size_type i = size_; i < size_ + N; ++i) {
new (&buffer[i]) T(); new (&buffer[i]) T();

@ -45,8 +45,6 @@ public:
void clear_old_pdus(tti_point current_tti); void clear_old_pdus(tti_point current_tti);
void remove_pdu(tti_point tti);
bool try_deallocate_pdu(tti_point tti); bool try_deallocate_pdu(tti_point tti);
void clear(); void clear();
@ -56,6 +54,8 @@ public:
bool has_tti(tti_point tti) const; bool has_tti(tti_point tti) const;
private: private:
void remove_pdu(tti_point tti);
srslog::basic_logger* logger; srslog::basic_logger* logger;
srslte::pdu_queue* shared_pdu_queue; srslte::pdu_queue* shared_pdu_queue;
@ -183,7 +183,7 @@ private:
int nof_rx_harq_proc = 0; int nof_rx_harq_proc = 0;
int nof_tx_harq_proc = 0; int nof_tx_harq_proc = 0;
std::vector<cc_buffer_handler> cc_buffers; srslte::bounded_vector<cc_buffer_handler, SRSLTE_MAX_CARRIERS> cc_buffers;
std::mutex rx_buffers_mutex; std::mutex rx_buffers_mutex;

@ -210,7 +210,6 @@ ue::ue(uint16_t rnti_,
nof_tx_harq_proc(nof_tx_harq_proc_), nof_tx_harq_proc(nof_tx_harq_proc_),
ta_fsm(this) ta_fsm(this)
{ {
cc_buffers.reserve(nof_cells_);
for (size_t i = 0; i < nof_cells_; ++i) { for (size_t i = 0; i < nof_cells_; ++i) {
cc_buffers.emplace_back(pdus); cc_buffers.emplace_back(pdus);
} }
@ -255,7 +254,7 @@ srslte_softbuffer_rx_t* ue::get_rx_softbuffer(const uint32_t ue_cc_idx, const ui
return nullptr; return nullptr;
} }
return &cc_buffers.at(ue_cc_idx).get_rx_softbuffer(tti % nof_rx_harq_proc); return &cc_buffers[ue_cc_idx].get_rx_softbuffer(tti % nof_rx_harq_proc);
} }
srslte_softbuffer_tx_t* srslte_softbuffer_tx_t*
@ -274,7 +273,7 @@ uint8_t* ue::request_buffer(uint32_t tti, uint32_t ue_cc_idx, const uint32_t len
std::unique_lock<std::mutex> lock(rx_buffers_mutex); std::unique_lock<std::mutex> lock(rx_buffers_mutex);
uint8_t* pdu = nullptr; uint8_t* pdu = nullptr;
if (len > 0) { if (len > 0) {
pdu = cc_buffers.at(ue_cc_idx).get_rx_used_buffers().request_pdu(tti_point(tti), len); pdu = cc_buffers[ue_cc_idx].get_rx_used_buffers().request_pdu(tti_point(tti), len);
} else { } else {
logger.error("UE buffers: Requesting buffer for zero bytes"); logger.error("UE buffers: Requesting buffer for zero bytes");
} }
@ -422,7 +421,7 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe
void ue::deallocate_pdu(uint32_t tti, uint32_t ue_cc_idx) void ue::deallocate_pdu(uint32_t tti, uint32_t ue_cc_idx)
{ {
std::unique_lock<std::mutex> lock(rx_buffers_mutex); std::unique_lock<std::mutex> lock(rx_buffers_mutex);
if (not cc_buffers.at(ue_cc_idx).get_rx_used_buffers().try_deallocate_pdu(tti_point(tti))) { if (not cc_buffers[ue_cc_idx].get_rx_used_buffers().try_deallocate_pdu(tti_point(tti))) {
logger.warning("UE buffers: Null RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d cc_idx=%d", logger.warning("UE buffers: Null RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d cc_idx=%d",
rnti, rnti,
tti % nof_rx_harq_proc, tti % nof_rx_harq_proc,
@ -433,7 +432,7 @@ void ue::deallocate_pdu(uint32_t tti, uint32_t ue_cc_idx)
void ue::push_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len) void ue::push_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len)
{ {
std::unique_lock<std::mutex> lock(rx_buffers_mutex); std::unique_lock<std::mutex> lock(rx_buffers_mutex);
if (not cc_buffers.at(ue_cc_idx).get_rx_used_buffers().push_pdu(tti_point(tti), len)) { if (not cc_buffers[ue_cc_idx].get_rx_used_buffers().push_pdu(tti_point(tti), len)) {
logger.warning( logger.warning(
"UE buffers: Failed to push RX PDU for rnti=0x%x pid=%d cc_idx=%d", rnti, tti % nof_rx_harq_proc, ue_cc_idx); "UE buffers: Failed to push RX PDU for rnti=0x%x pid=%d cc_idx=%d", rnti, tti % nof_rx_harq_proc, ue_cc_idx);
} }

Loading…
Cancel
Save