Commit 3a7c9ef8 authored by aligungr's avatar aligungr

Performance improvements

parent a34a7da2
//
// This file is a part of UERANSIM open source project.
// Copyright (c) 2021 ALİ GÜNGÖR.
//
// The software and all associated files are licensed under GPL-3.0
// and subject to the terms and conditions defined in LICENSE file.
//
#include "task.hpp"
#include "cmd_handler.hpp"
#include <ue/tun/config.hpp>
namespace nr::ue
{
UeAppTask::UeAppTask(TaskBase *base) : m_base{base}
{
m_logger = m_base->logBase->makeUniqueLogger(m_base->config->getLoggerPrefix() + "app");
}
void UeAppTask::onStart()
{
}
void UeAppTask::onQuit()
{
}
void UeAppTask::onLoop()
{
auto msg = take();
if (!msg)
return;
switch (msg->msgType)
{
case NtsMessageType::UE_CLI_COMMAND: {
auto &w = dynamic_cast<NmUeCliCommand &>(*msg);
UeCmdHandler handler{m_base};
handler.handleCmd(w);
break;
}
default:
m_logger->unhandledNts(*msg);
break;
}
}
} // namespace nr::ue
//
// This file is a part of UERANSIM open source project.
// Copyright (c) 2021 ALİ GÜNGÖR.
//
// The software and all associated files are licensed under GPL-3.0
// and subject to the terms and conditions defined in LICENSE file.
//
#pragma once
#include <memory>
#include <thread>
#include <ue/nts.hpp>
#include <ue/tun/layer.hpp>
#include <ue/types.hpp>
#include <unordered_map>
#include <utils/logger.hpp>
#include <utils/nts.hpp>
#include <vector>
namespace nr::ue
{
class UeAppTask : public NtsTask
{
private:
TaskBase *m_base;
std::unique_ptr<Logger> m_logger;
friend class UeCmdHandler;
public:
explicit UeAppTask(TaskBase *base);
~UeAppTask() override = default;
protected:
void onStart() override;
void onLoop() override;
void onQuit() override;
};
} // namespace nr::ue
......@@ -6,9 +6,9 @@
// and subject to the terms and conditions defined in LICENSE file.
//
#include "cmd_handler.hpp"
#include "cmd.hpp"
#include <ue/app/task.hpp>
#include <ue/cmd.hpp>
#include <ue/l23/task.hpp>
#include <utils/common.hpp>
#include <utils/printer.hpp>
......
......@@ -8,9 +8,8 @@
#pragma once
#include <ue/nts.hpp>
#include <ue/types.hpp>
#include "ue/l23/task.hpp"
#include "nts.hpp"
#include "types.hpp"
namespace nr::ue
{
......
......@@ -9,6 +9,7 @@
#include "task.hpp"
#include <utils/random.hpp>
#include <ue/cmd.hpp>
struct TimerId
{
......@@ -116,6 +117,12 @@ void UeL23Task::onLoop()
{
setTimer(TimerId::SWITCH_OFF, TimerPeriod::SWITCH_OFF);
}
else if (msg->msgType == NtsMessageType::UE_CLI_COMMAND)
{
auto &w = dynamic_cast<NmUeCliCommand &>(*msg);
UeCmdHandler handler{m_base};
handler.handleCmd(w);
}
else
{
m_logger->unhandledNts(*msg);
......
......@@ -9,7 +9,6 @@
#include "mm.hpp"
#include <lib/nas/utils.hpp>
#include <ue/app/task.hpp>
#include <ue/l23/task.hpp>
#include <ue/nas/usim/usim.hpp>
#include <utils/common.hpp>
......
......@@ -9,7 +9,6 @@
#include "mm.hpp"
#include <lib/nas/utils.hpp>
#include <ue/app/task.hpp>
namespace nr::ue
{
......
......@@ -11,9 +11,7 @@
#include <algorithm>
#include <lib/nas/utils.hpp>
#include <ue/app/task.hpp>
#include <ue/nas/sm/sm.hpp>
#include <utils/common.hpp>
namespace nr::ue
{
......
......@@ -11,7 +11,6 @@
#include <algorithm>
#include <lib/nas/utils.hpp>
#include <ue/app/task.hpp>
#include <ue/l23/task.hpp>
#include <ue/nas/sm/sm.hpp>
#include <utils/common.hpp>
......
......@@ -8,7 +8,6 @@
#include "mm.hpp"
#include <lib/nas/utils.hpp>
#include <ue/app/task.hpp>
#include <ue/nas/sm/sm.hpp>
namespace nr::ue
......
......@@ -9,7 +9,6 @@
#include "mm.hpp"
#include <lib/nas/utils.hpp>
#include <ue/app/task.hpp>
namespace nr::ue
{
......
......@@ -10,7 +10,6 @@
#include <algorithm>
#include <lib/nas/proto_conf.hpp>
#include <lib/nas/utils.hpp>
#include <ue/app/task.hpp>
#include <ue/nas/mm/mm.hpp>
namespace nr::ue
......
......@@ -7,9 +7,10 @@
//
#include "sm.hpp"
#include <lib/nas/utils.hpp>
#include <set>
#include <ue/app/task.hpp>
#include <lib/nas/utils.hpp>
#include <ue/nas/mm/mm.hpp>
namespace nr::ue
......
......@@ -10,7 +10,6 @@
#include <lib/nas/proto_conf.hpp>
#include <lib/nas/utils.hpp>
#include <optional>
#include <ue/app/task.hpp>
#include <ue/l23/task.hpp>
#include <ue/nas/mm/mm.hpp>
......
......@@ -10,7 +10,6 @@
#include <algorithm>
#include <lib/nas/proto_conf.hpp>
#include <lib/nas/utils.hpp>
#include <ue/app/task.hpp>
#include <ue/l23/task.hpp>
#include <ue/nas/mm/mm.hpp>
......
......@@ -11,7 +11,6 @@
#include <algorithm>
#include <lib/nas/proto_conf.hpp>
#include <ue/app/task.hpp>
#include <ue/l23/task.hpp>
#include <ue/nas/mm/mm.hpp>
......
......@@ -7,10 +7,8 @@
//
#include "sm.hpp"
#include <algorithm>
#include <lib/nas/proto_conf.hpp>
#include <lib/nas/utils.hpp>
#include <ue/app/task.hpp>
#include <ue/nas/mm/mm.hpp>
namespace nr::ue
......
......@@ -14,7 +14,6 @@
#include <asn/rrc/ASN_RRC_ULInformationTransfer.h>
#include <lib/rrc/encode.hpp>
#include <ue/app/task.hpp>
#include <utils/common.hpp>
namespace nr::ue
......
......@@ -197,7 +197,6 @@ struct TaskBase
UeSharedContext shCtx{};
UeAppTask *appTask{};
UeL23Task *l23Task{};
};
......
......@@ -8,7 +8,6 @@
#include "ue.hpp"
#include "app/task.hpp"
#include "l23/task.hpp"
namespace nr::ue
......@@ -26,7 +25,6 @@ UserEquipment::UserEquipment(UeConfig *config, app::IUeController *ueController,
base->cliCallbackTask = cliCallbackTask;
base->l23Task = new UeL23Task(base);
base->appTask = new UeAppTask(base);
taskBase = base;
}
......@@ -34,10 +32,8 @@ UserEquipment::UserEquipment(UeConfig *config, app::IUeController *ueController,
UserEquipment::~UserEquipment()
{
taskBase->l23Task->quit();
taskBase->appTask->quit();
delete taskBase->l23Task;
delete taskBase->appTask;
delete taskBase->logBase;
......@@ -47,12 +43,11 @@ UserEquipment::~UserEquipment()
void UserEquipment::start()
{
taskBase->l23Task->start();
taskBase->appTask->start();
}
void UserEquipment::pushCommand(std::unique_ptr<app::UeCliCommand> cmd, const InetAddress &address)
{
taskBase->appTask->push(std::make_unique<NmUeCliCommand>(std::move(cmd), address));
taskBase->l23Task->push(std::make_unique<NmUeCliCommand>(std::move(cmd), address));
}
} // namespace nr::ue
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment