From 039977aeb578217aa33b92d68d3272cb053a1566 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Thu, 9 Jul 2020 00:13:55 +0100 Subject: [PATCH] renamed interfaces --- lib/include/srslte/common/interfaces_common.h | 13 +++++----- lib/include/srslte/common/multiqueue.h | 13 +++++----- lib/include/srslte/common/task_scheduler.h | 13 ++++------ lib/include/srslte/common/timers.h | 2 ++ lib/include/srslte/test/ue_test_interfaces.h | 9 ++++--- srsenb/hdr/stack/enb_stack_lte.h | 17 +++++++------ srsenb/hdr/stack/gnb_stack_nr.h | 22 +++++++---------- srsenb/hdr/stack/mac/mac.h | 2 +- srsenb/src/stack/enb_stack_lte.cc | 9 ++----- srsue/hdr/stack/mac/mac.h | 4 ++-- srsue/hdr/stack/mac/mac_nr.h | 2 +- srsue/hdr/stack/ue_stack_lte.h | 24 ++++++++----------- srsue/hdr/stack/ue_stack_nr.h | 20 +++++++--------- 13 files changed, 65 insertions(+), 85 deletions(-) diff --git a/lib/include/srslte/common/interfaces_common.h b/lib/include/srslte/common/interfaces_common.h index f8b917fda..7819686dc 100644 --- a/lib/include/srslte/common/interfaces_common.h +++ b/lib/include/srslte/common/interfaces_common.h @@ -91,13 +91,12 @@ public: class task_handler_interface { public: - virtual srslte::timer_handler::unique_timer get_unique_timer() = 0; - virtual srslte::task_multiqueue::queue_handler make_task_queue() = 0; - virtual srslte::task_multiqueue::queue_handler make_task_queue(uint32_t queue_size) = 0; - virtual void defer_callback(uint32_t duration_ms, std::function func) = 0; - virtual void defer_task(srslte::move_task_t func) = 0; - virtual void enqueue_background_task(std::function task) = 0; - virtual void notify_background_task_result(srslte::move_task_t task) = 0; + virtual srslte::timer_handler::unique_timer get_unique_timer() = 0; + virtual srslte::task_multiqueue::queue_handle make_task_queue() = 0; + virtual void defer_callback(uint32_t duration_ms, std::function func) = 0; + virtual void defer_task(srslte::move_task_t func) = 0; + virtual void enqueue_background_task(std::function task) = 0; + virtual void notify_background_task_result(srslte::move_task_t task) = 0; }; class stack_interface_phy_nr diff --git a/lib/include/srslte/common/multiqueue.h b/lib/include/srslte/common/multiqueue.h index a69390007..64d0b534e 100644 --- a/lib/include/srslte/common/multiqueue.h +++ b/lib/include/srslte/common/multiqueue.h @@ -90,11 +90,11 @@ class multiqueue_handler }; public: - class queue_handler + class queue_handle { public: - queue_handler() = default; - queue_handler(multiqueue_handler* parent_, int id) : parent(parent_), queue_id(id) {} + queue_handle() = default; + queue_handle(multiqueue_handler* parent_, int id) : parent(parent_), queue_id(id) {} template void push(FwdRef&& value) { @@ -293,8 +293,8 @@ public: return is_queue_active_(qidx); } - queue_handler get_queue_handler() { return {this, add_queue()}; } - queue_handler get_queue_handler(uint32_t size) { return {this, add_queue(size)}; } + queue_handle get_queue_handler() { return {this, add_queue()}; } + queue_handle get_queue_handler(uint32_t size) { return {this, add_queue(size)}; } private: bool is_queue_active_(int qidx) const { return running and queues[qidx].active; } @@ -325,7 +325,8 @@ private: }; //! Specialization for tasks -using task_multiqueue = multiqueue_handler; +using task_multiqueue = multiqueue_handler; +using task_queue_handle = task_multiqueue::queue_handle; } // namespace srslte diff --git a/lib/include/srslte/common/task_scheduler.h b/lib/include/srslte/common/task_scheduler.h index 6ec40f505..03349983b 100644 --- a/lib/include/srslte/common/task_scheduler.h +++ b/lib/include/srslte/common/task_scheduler.h @@ -52,14 +52,11 @@ public: external_tasks.reset(); } - srslte::timer_handler::unique_timer get_unique_timer() final { return timers.get_unique_timer(); } + srslte::unique_timer get_unique_timer() final { return timers.get_unique_timer(); } //! Creates new queue for tasks coming from external thread - srslte::task_multiqueue::queue_handler make_task_queue() final { return external_tasks.get_queue_handler(); } - srslte::task_multiqueue::queue_handler make_task_queue(uint32_t size) final - { - return external_tasks.get_queue_handler(size); - } + srslte::task_queue_handle make_task_queue() final { return external_tasks.get_queue_handler(); } + srslte::task_queue_handle make_task_queue(uint32_t qsize) { return external_tasks.get_queue_handler(qsize); } //! Delays a task processing by duration_ms void defer_callback(uint32_t duration_ms, std::function func) final @@ -140,13 +137,13 @@ private: std::vector internal_tasks; ///< enqueues stack tasks from within main thread. Avoids locking }; -//! Handle to provide to classes/functions running within main thread +//! Task scheduler handle given to classes/functions running within the main control thread class task_sched_handle { public: task_sched_handle(task_scheduler* sched_) : sched(sched_) {} - srslte::timer_handler::unique_timer get_unique_timer() { return sched->get_unique_timer(); } + srslte::unique_timer get_unique_timer() { return sched->get_unique_timer(); } void enqueue_background_task(std::function f) { sched->enqueue_background_task(std::move(f)); } void notify_background_task_result(srslte::move_task_t task) { diff --git a/lib/include/srslte/common/timers.h b/lib/include/srslte/common/timers.h index 579b5306d..e76de04cb 100644 --- a/lib/include/srslte/common/timers.h +++ b/lib/include/srslte/common/timers.h @@ -330,6 +330,8 @@ private: std::mutex mutex; // Protect priority queue }; +using unique_timer = timer_handler::unique_timer; + } // namespace srslte #endif // SRSLTE_TIMERS_H diff --git a/lib/include/srslte/test/ue_test_interfaces.h b/lib/include/srslte/test/ue_test_interfaces.h index 2d486c367..3a0491c8a 100644 --- a/lib/include/srslte/test/ue_test_interfaces.h +++ b/lib/include/srslte/test/ue_test_interfaces.h @@ -39,11 +39,10 @@ public: { return srslte::tti_point{task_sched.get_timer_handler()->get_cur_time() % 10240}; } - srslte::task_multiqueue::queue_handler make_task_queue() final { return task_sched.make_task_queue(); } - srslte::task_multiqueue::queue_handler make_task_queue(uint32_t len) final { return task_sched.make_task_queue(len); } - void enqueue_background_task(std::function f) override { f(0); } - void notify_background_task_result(srslte::move_task_t task) override { task(); } - void defer_callback(uint32_t duration_ms, std::function func) final + srslte::task_multiqueue::queue_handle make_task_queue() final { return task_sched.make_task_queue(); } + void enqueue_background_task(std::function f) override { f(0); } + void notify_background_task_result(srslte::move_task_t task) override { task(); } + void defer_callback(uint32_t duration_ms, std::function func) final { task_sched.defer_callback(duration_ms, std::move(func)); } diff --git a/srsenb/hdr/stack/enb_stack_lte.h b/srsenb/hdr/stack/enb_stack_lte.h index aa1d8aeb4..99789f809 100644 --- a/srsenb/hdr/stack/enb_stack_lte.h +++ b/srsenb/hdr/stack/enb_stack_lte.h @@ -110,13 +110,12 @@ public: void add_gtpu_m1u_socket_handler(int fd) override; /* Stack-MAC interface */ - srslte::timer_handler::unique_timer get_unique_timer() final; - srslte::task_multiqueue::queue_handler make_task_queue() final; - srslte::task_multiqueue::queue_handler make_task_queue(uint32_t qsize) final; - void defer_callback(uint32_t duration_ms, std::function func) final; - void enqueue_background_task(std::function task) final; - void notify_background_task_result(srslte::move_task_t task) final; - void defer_task(srslte::move_task_t task) final; + srslte::unique_timer get_unique_timer() final; + srslte::task_queue_handle make_task_queue() final; + void defer_callback(uint32_t duration_ms, std::function func) final; + void enqueue_background_task(std::function task) final; + void notify_background_task_result(srslte::move_task_t task) final; + void defer_task(srslte::move_task_t task) final; private: static const int STACK_MAIN_THREAD_PRIO = 4; @@ -134,8 +133,8 @@ private: rrc_cfg_t rrc_cfg = {}; // task handling - srslte::task_scheduler task_sched; - srslte::task_multiqueue::queue_handler enb_task_queue, gtpu_task_queue, mme_task_queue, sync_task_queue; + srslte::task_scheduler task_sched; + srslte::task_queue_handle enb_task_queue, gtpu_task_queue, mme_task_queue, sync_task_queue; // components that layers depend on (need to be destroyed after layers) std::unique_ptr rx_sockets; diff --git a/srsenb/hdr/stack/gnb_stack_nr.h b/srsenb/hdr/stack/gnb_stack_nr.h index 9ed70de67..01340126a 100644 --- a/srsenb/hdr/stack/gnb_stack_nr.h +++ b/srsenb/hdr/stack/gnb_stack_nr.h @@ -80,16 +80,12 @@ public: void process_pdus() final; // Task Handling interface - srslte::timer_handler::unique_timer get_unique_timer() final { return task_sched.get_unique_timer(); } - srslte::task_multiqueue::queue_handler make_task_queue() final { return task_sched.make_task_queue(); } - srslte::task_multiqueue::queue_handler make_task_queue(uint32_t qsize) final - { - return task_sched.make_task_queue(qsize); - } - void enqueue_background_task(std::function f) final; - void notify_background_task_result(srslte::move_task_t task) final; - void defer_callback(uint32_t duration_ms, std::function func) final; - void defer_task(srslte::move_task_t task) final; + srslte::timer_handler::unique_timer get_unique_timer() final { return task_sched.get_unique_timer(); } + srslte::task_multiqueue::queue_handle make_task_queue() final { return task_sched.make_task_queue(); } + void enqueue_background_task(std::function f) final; + void notify_background_task_result(srslte::move_task_t task) final; + void defer_callback(uint32_t duration_ms, std::function func) final; + void defer_task(srslte::move_task_t task) final; private: void run_thread() final; @@ -101,9 +97,9 @@ private: phy_interface_stack_nr* phy = nullptr; // task scheduling - static const int STACK_MAIN_THREAD_PRIO = 4; - srslte::task_scheduler task_sched; - srslte::task_multiqueue::queue_handler sync_task_queue, ue_task_queue, gw_task_queue, mac_task_queue; + static const int STACK_MAIN_THREAD_PRIO = 4; + srslte::task_scheduler task_sched; + srslte::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gw_task_queue, mac_task_queue; // derived std::unique_ptr m_mac; diff --git a/srsenb/hdr/stack/mac/mac.h b/srsenb/hdr/stack/mac/mac.h index 1fd3dce94..55cefb147 100644 --- a/srsenb/hdr/stack/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -124,7 +124,7 @@ private: mac_args_t args = {}; // derived from args - srslte::task_multiqueue::queue_handler stack_task_queue; + srslte::task_multiqueue::queue_handle stack_task_queue; bool started = false; diff --git a/srsenb/src/stack/enb_stack_lte.cc b/srsenb/src/stack/enb_stack_lte.cc index 3d6868e9f..85d7534fe 100644 --- a/srsenb/src/stack/enb_stack_lte.cc +++ b/srsenb/src/stack/enb_stack_lte.cc @@ -248,21 +248,16 @@ void enb_stack_lte::add_gtpu_m1u_socket_handler(int fd) rx_sockets->add_socket_pdu_handler(fd, gtpu_m1u_handler); } -srslte::timer_handler::unique_timer enb_stack_lte::get_unique_timer() +srslte::unique_timer enb_stack_lte::get_unique_timer() { return task_sched.get_unique_timer(); } -srslte::task_multiqueue::queue_handler enb_stack_lte::make_task_queue() +srslte::task_queue_handle enb_stack_lte::make_task_queue() { return task_sched.make_task_queue(); } -srslte::task_multiqueue::queue_handler enb_stack_lte::make_task_queue(uint32_t qsize) -{ - return task_sched.make_task_queue(qsize); -} - void enb_stack_lte::defer_callback(uint32_t duration_ms, std::function func) { task_sched.defer_callback(duration_ms, std::move(func)); diff --git a/srsue/hdr/stack/mac/mac.h b/srsue/hdr/stack/mac/mac.h index defffa0ff..340cfe7cd 100644 --- a/srsue/hdr/stack/mac/mac.h +++ b/srsue/hdr/stack/mac/mac.h @@ -163,8 +163,8 @@ private: void timer_alignment_expire(); /* Queue to dispatch stack tasks */ - srslte::task_multiqueue::queue_handler stack_task_dispatch_queue; - srslte::byte_buffer_pool* pool = nullptr; + srslte::task_multiqueue::queue_handle stack_task_dispatch_queue; + srslte::byte_buffer_pool* pool = nullptr; // pointer to MAC PCAP object srslte::mac_pcap* pcap = nullptr; diff --git a/srsue/hdr/stack/mac/mac_nr.h b/srsue/hdr/stack/mac/mac_nr.h index 187816142..32b834af2 100644 --- a/srsue/hdr/stack/mac/mac_nr.h +++ b/srsue/hdr/stack/mac/mac_nr.h @@ -111,7 +111,7 @@ private: srslte::unique_byte_buffer_t tx_buffer = nullptr; srslte::unique_byte_buffer_t rlc_buffer = nullptr; - srslte::task_multiqueue::queue_handler stack_task_dispatch_queue; + srslte::task_multiqueue::queue_handle stack_task_dispatch_queue; }; } // namespace srsue diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index c9a760a40..1fc9b49d0 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -126,16 +126,12 @@ public: tti_point get_current_tti() final { return current_tti; } // Task Handling interface - srslte::timer_handler::unique_timer get_unique_timer() final { return task_sched.get_unique_timer(); } - srslte::task_multiqueue::queue_handler make_task_queue() final { return task_sched.make_task_queue(); } - srslte::task_multiqueue::queue_handler make_task_queue(uint32_t queue_size) final - { - return task_sched.make_task_queue(queue_size); - } - void enqueue_background_task(std::function f) final; - void notify_background_task_result(srslte::move_task_t task) final; - void defer_callback(uint32_t duration_ms, std::function func) final; - void defer_task(srslte::move_task_t task) final; + srslte::unique_timer get_unique_timer() final { return task_sched.get_unique_timer(); } + srslte::task_multiqueue::queue_handle make_task_queue() final { return task_sched.make_task_queue(); } + void enqueue_background_task(std::function f) final; + void notify_background_task_result(srslte::move_task_t task) final; + void defer_callback(uint32_t duration_ms, std::function func) final; + void defer_task(srslte::move_task_t task) final; private: void run_thread() final; @@ -167,10 +163,10 @@ private: gw_interface_stack* gw = nullptr; // Thread - static const int STACK_MAIN_THREAD_PRIO = 4; // Next lower priority after PHY workers - srslte::block_queue pending_stack_metrics; - task_scheduler task_sched; - srslte::task_multiqueue::queue_handler sync_task_queue, ue_task_queue, gw_queue_id; + static const int STACK_MAIN_THREAD_PRIO = 4; // Next lower priority after PHY workers + srslte::block_queue pending_stack_metrics; + task_scheduler task_sched; + srslte::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gw_queue_id; // TTI stats srslte::tprof tti_tprof; diff --git a/srsue/hdr/stack/ue_stack_nr.h b/srsue/hdr/stack/ue_stack_nr.h index 8b64591eb..d803fbb61 100644 --- a/srsue/hdr/stack/ue_stack_nr.h +++ b/srsue/hdr/stack/ue_stack_nr.h @@ -97,16 +97,12 @@ public: srslte::tti_point get_current_tti() { return srslte::tti_point{0}; }; // Task Handling interface - srslte::timer_handler::unique_timer get_unique_timer() final { return task_sched.get_unique_timer(); } - srslte::task_multiqueue::queue_handler make_task_queue() final { return task_sched.make_task_queue(); } - srslte::task_multiqueue::queue_handler make_task_queue(uint32_t qsize) final - { - return task_sched.make_task_queue(qsize); - } - void enqueue_background_task(std::function f) final; - void notify_background_task_result(srslte::move_task_t task) final; - void defer_callback(uint32_t duration_ms, std::function func) final; - void defer_task(srslte::move_task_t task) final; + srslte::timer_handler::unique_timer get_unique_timer() final { return task_sched.get_unique_timer(); } + srslte::task_multiqueue::queue_handle make_task_queue() final { return task_sched.make_task_queue(); } + void enqueue_background_task(std::function f) final; + void notify_background_task_result(srslte::move_task_t task) final; + void defer_callback(uint32_t duration_ms, std::function func) final; + void defer_task(srslte::move_task_t task) final; private: void run_thread() final; @@ -117,8 +113,8 @@ private: srsue::stack_args_t args = {}; // task scheduler - srslte::task_scheduler task_sched; - srslte::task_multiqueue::queue_handler sync_task_queue, ue_task_queue, gw_task_queue; + srslte::task_scheduler task_sched; + srslte::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gw_task_queue; // UE stack logging srslte::logger* logger = nullptr;