Commit b41ecee9 authored by aligungr's avatar aligungr

UE/gNB executable refactor

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