Commit b41ecee9 authored by aligungr's avatar aligungr

UE/gNB executable refactor

parent f0d63a86
...@@ -8,13 +8,18 @@ ...@@ -8,13 +8,18 @@
#pragma once #pragma once
namespace nr::ue
{
class UserEquipment;
}
namespace app namespace app
{ {
class IUeController class IUeController
{ {
public: public:
virtual void performSwitchOff() = 0; virtual void performSwitchOff(nr::ue::UserEquipment *ue) = 0;
}; };
} // namespace app } // namespace app
...@@ -329,16 +329,24 @@ static void Loop() ...@@ -329,16 +329,24 @@ static void Loop()
class UeController : public app::IUeController class UeController : public app::IUeController
{ {
public: public:
void performSwitchOff() override void performSwitchOff(nr::ue::UserEquipment *ue) override
{ {
// WARNING: This method is executed in UE AppTask's thread. // WARNING: This method is executed in UE AppTask's thread.
// Therefore be careful about thread safety. // Therefore be careful about thread safety.
// todo ue' için ptr çek std::string key{};
// o ptru delete et g_ueMap.invokeForeach([&key, ue](auto &item) {
// mapten sil if (item.second == ue)
// map boşaldıysa exit yap key = item.first;
// tabi bunları switc off olan appin kendi threadin yapıyoz o yüzden burası atomic değil dikkat!! });
if (key.empty())
return;
if (g_ueMap.removeAndGetSize(key) == 0)
exit(0);
delete ue;
} }
} g_ueController; } g_ueController;
......
...@@ -112,7 +112,7 @@ void UeAppTask::onLoop() ...@@ -112,7 +112,7 @@ void UeAppTask::onLoop()
if (w->timerId == SWITCH_OFF_TIMER_ID) if (w->timerId == SWITCH_OFF_TIMER_ID)
{ {
m_logger->info("UE device is switching off"); m_logger->info("UE device is switching off");
m_base->ueController->performSwitchOff(); m_base->ueController->performSwitchOff(m_base->ue);
} }
break; break;
} }
......
...@@ -25,6 +25,7 @@ class UeAppTask; ...@@ -25,6 +25,7 @@ class UeAppTask;
class UeMrTask; class UeMrTask;
class NasTask; class NasTask;
class UeRrcTask; class UeRrcTask;
class UserEquipment;
struct SupportedAlgs struct SupportedAlgs
{ {
...@@ -97,6 +98,7 @@ struct UeConfig ...@@ -97,6 +98,7 @@ struct UeConfig
struct TaskBase struct TaskBase
{ {
UserEquipment *ue{};
UeConfig *config{}; UeConfig *config{};
LogBase *logBase{}; LogBase *logBase{};
app::IUeController *ueController{}; app::IUeController *ueController{};
......
...@@ -20,6 +20,7 @@ UserEquipment::UserEquipment(UeConfig *config, app::IUeController *ueController, ...@@ -20,6 +20,7 @@ UserEquipment::UserEquipment(UeConfig *config, app::IUeController *ueController,
NtsTask *cliCallbackTask) NtsTask *cliCallbackTask)
{ {
auto *base = new TaskBase(); auto *base = new TaskBase();
base->ue = this;
base->config = config; base->config = config;
base->logBase = new LogBase("logs/ue-" + config->getNodeName() + ".log"); base->logBase = new LogBase("logs/ue-" + config->getNodeName() + ".log");
base->ueController = ueController; base->ueController = ueController;
......
...@@ -43,4 +43,17 @@ class ConcurrentMap ...@@ -43,4 +43,17 @@ class ConcurrentMap
for (auto i : m_map) for (auto i : m_map)
fun(i); fun(i);
} }
void remove(const TKey &key)
{
std::lock_guard lk(m_mutex);
m_map.erase(key);
}
size_t removeAndGetSize(const TKey &key)
{
std::lock_guard lk(m_mutex);
m_map.erase(key);
return m_map.size();
}
}; };
\ No newline at end of file
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