From 0e95867f13f2b8352f6f8271733ec79a344f2f17 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 27 May 2019 12:08:24 +0200 Subject: [PATCH] remove task dispatcher class --- lib/include/srslte/common/task_dispatcher.h | 56 ----------------- lib/src/common/task_dispatcher.cc | 69 --------------------- srsenb/hdr/phy/phy.h | 1 - srsue/hdr/phy/phy.h | 1 - 4 files changed, 127 deletions(-) delete mode 100644 lib/include/srslte/common/task_dispatcher.h delete mode 100644 lib/src/common/task_dispatcher.cc diff --git a/lib/include/srslte/common/task_dispatcher.h b/lib/include/srslte/common/task_dispatcher.h deleted file mode 100644 index 472c1fb8e..000000000 --- a/lib/include/srslte/common/task_dispatcher.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2013-2019 Software Radio Systems Limited - * - * This file is part of srsLTE. - * - * srsLTE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsLTE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * A copy of the GNU Affero General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - -/****************************************************************************** - * File: task_dispatcher.h - * Description: - * Reference: - *****************************************************************************/ - -#ifndef SRSLTE_TASK_DISPATCHER_H -#define SRSLTE_TASK_DISPATCHER_H - -#include -#include -#include -#include -#include "srslte/common/threads.h" - -namespace srslte { - -class task_dispatcher : public thread -{ -public: - task_dispatcher(uint32_t max_pending_tasks); - ~task_dispatcher(); - void push_task(uint32_t task_code); - virtual void run_task(uint32_t task_code) = 0; -private: - std::queue pending_tasks; - void run_thread(); - pthread_mutex_t mutex; - pthread_cond_t cvar; - bool running; -}; - -} // namespace srslte - -#endif // SRSLTE_TASK_DISPATCHER_H diff --git a/lib/src/common/task_dispatcher.cc b/lib/src/common/task_dispatcher.cc deleted file mode 100644 index f5c669d16..000000000 --- a/lib/src/common/task_dispatcher.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2013-2019 Software Radio Systems Limited - * - * This file is part of srsLTE. - * - * srsLTE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsLTE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * A copy of the GNU Affero General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - -#include "srslte/common/task_dispatcher.h" -#include - -namespace srslte { - -task_dispatcher::task_dispatcher(uint32_t max_pending_tasks) -{ - pthread_cond_init(&cvar, NULL); - pthread_mutex_init(&mutex, NULL); -} - -task_dispatcher::~task_dispatcher() -{ - running = false; - pthread_cond_signal(&cvar); - wait_thread_finish(); - pthread_cond_destroy(&cvar); - pthread_mutex_destroy(&mutex); -} - -void task_dispatcher::push_task(uint32_t task_code) -{ - pthread_mutex_lock(&mutex); - pending_tasks.push(task_code); - pthread_cond_signal(&cvar); - pthread_mutex_unlock(&mutex); -} - -void task_dispatcher::run_thread() -{ - running = true; - while(running) { - uint32_t task = 0; - pthread_mutex_lock(&mutex); - while(pending_tasks.empty()) { - pthread_cond_wait(&cvar, &mutex); - } - task = (uint32_t) pending_tasks.front(); - pending_tasks.pop(); - pthread_mutex_unlock(&mutex); - if (running) { - run_task(task); - } - } -} - - -} \ No newline at end of file diff --git a/srsenb/hdr/phy/phy.h b/srsenb/hdr/phy/phy.h index 06ef8f52f..70b93dbe0 100644 --- a/srsenb/hdr/phy/phy.h +++ b/srsenb/hdr/phy/phy.h @@ -26,7 +26,6 @@ #include "sf_worker.h" #include "srslte/common/log.h" #include "srslte/common/log_filter.h" -#include "srslte/common/task_dispatcher.h" #include "srslte/common/trace.h" #include "srslte/interfaces/enb_interfaces.h" #include "srslte/interfaces/enb_metrics_interface.h" diff --git a/srsue/hdr/phy/phy.h b/srsue/hdr/phy/phy.h index 1c53c96de..48878a2aa 100644 --- a/srsue/hdr/phy/phy.h +++ b/srsue/hdr/phy/phy.h @@ -28,7 +28,6 @@ #include "prach.h" #include "sf_worker.h" #include "srslte/common/log_filter.h" -#include "srslte/common/task_dispatcher.h" #include "srslte/common/trace.h" #include "srslte/interfaces/ue_interfaces.h" #include "srslte/radio/radio.h"