Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
UERANSIM
Commits
d9bfa152
Commit
d9bfa152
authored
Feb 20, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UE/gNB executable refactor
parent
54f7e1ff
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
6 deletions
+70
-6
src/app/proc_table.hpp
src/app/proc_table.hpp
+9
-0
src/ue.cpp
src/ue.cpp
+6
-6
src/utils/concurrent_map.cpp
src/utils/concurrent_map.cpp
+9
-0
src/utils/concurrent_map.hpp
src/utils/concurrent_map.hpp
+46
-0
No files found.
src/app/proc_table.hpp
View file @
d9bfa152
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <string>
#include <string>
#include <unordered_map>
#include <unordered_map>
#include <utils/concurrent_map.hpp>
#include <vector>
#include <vector>
namespace
app
namespace
app
...
@@ -41,4 +42,12 @@ inline void CreateProcTable(const std::unordered_map<std::string, T> &nodeMap, i
...
@@ -41,4 +42,12 @@ inline void CreateProcTable(const std::unordered_map<std::string, T> &nodeMap, i
CreateProcTable
(
nodes
,
cmdPort
);
CreateProcTable
(
nodes
,
cmdPort
);
}
}
template
<
typename
T
>
inline
void
CreateProcTable
(
const
ConcurrentMap
<
std
::
string
,
T
>
&
nodeMap
,
int
cmdPort
)
{
std
::
vector
<
std
::
string
>
nodes
{};
nodeMap
.
invokeForeach
([
&
nodes
](
const
auto
&
node
)
{
nodes
.
push_back
(
node
.
first
);
});
CreateProcTable
(
nodes
,
cmdPort
);
}
}
// namespace app
}
// namespace app
src/ue.cpp
View file @
d9bfa152
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include <ue/ue.hpp>
#include <ue/ue.hpp>
#include <unistd.h>
#include <unistd.h>
#include <utils/common.hpp>
#include <utils/common.hpp>
#include <utils/concurrent_map.hpp>
#include <utils/constants.hpp>
#include <utils/constants.hpp>
#include <utils/options.hpp>
#include <utils/options.hpp>
#include <utils/yaml_utils.hpp>
#include <utils/yaml_utils.hpp>
...
@@ -22,7 +23,7 @@
...
@@ -22,7 +23,7 @@
static
app
::
CliServer
*
g_cliServer
=
nullptr
;
static
app
::
CliServer
*
g_cliServer
=
nullptr
;
static
nr
::
ue
::
UeConfig
*
g_refConfig
=
nullptr
;
static
nr
::
ue
::
UeConfig
*
g_refConfig
=
nullptr
;
static
std
::
unordered_m
ap
<
std
::
string
,
nr
::
ue
::
UserEquipment
*>
g_ueMap
{};
static
ConcurrentM
ap
<
std
::
string
,
nr
::
ue
::
UserEquipment
*>
g_ueMap
{};
static
app
::
CliResponseTask
*
g_cliRespTask
=
nullptr
;
static
app
::
CliResponseTask
*
g_cliRespTask
=
nullptr
;
static
struct
Options
static
struct
Options
...
@@ -282,13 +283,13 @@ static void ReceiveCommand(app::CliMessage &msg)
...
@@ -282,13 +283,13 @@ static void ReceiveCommand(app::CliMessage &msg)
return
;
return
;
}
}
if
(
g_ueMap
.
count
(
msg
.
nodeName
)
==
0
)
auto
*
ue
=
g_ueMap
.
getOrDefault
(
msg
.
nodeName
);
if
(
ue
==
nullptr
)
{
{
g_cliServer
->
sendMessage
(
app
::
CliMessage
::
Error
(
msg
.
clientAddr
,
"Node not found: "
+
msg
.
nodeName
));
g_cliServer
->
sendMessage
(
app
::
CliMessage
::
Error
(
msg
.
clientAddr
,
"Node not found: "
+
msg
.
nodeName
));
return
;
return
;
}
}
auto
*
ue
=
g_ueMap
[
msg
.
nodeName
];
ue
->
pushCommand
(
std
::
move
(
cmd
),
msg
.
clientAddr
);
ue
->
pushCommand
(
std
::
move
(
cmd
),
msg
.
clientAddr
);
}
}
...
@@ -367,7 +368,7 @@ int main(int argc, char **argv)
...
@@ -367,7 +368,7 @@ int main(int argc, char **argv)
{
{
auto
*
config
=
GetConfigByUe
(
i
);
auto
*
config
=
GetConfigByUe
(
i
);
auto
*
ue
=
new
nr
::
ue
::
UserEquipment
(
config
,
&
g_ueController
,
nullptr
,
g_cliRespTask
);
auto
*
ue
=
new
nr
::
ue
::
UserEquipment
(
config
,
&
g_ueController
,
nullptr
,
g_cliRespTask
);
g_ueMap
[
config
->
getNodeName
()]
=
ue
;
g_ueMap
.
put
(
config
->
getNodeName
(),
ue
)
;
}
}
if
(
!
g_options
.
disableCmd
)
if
(
!
g_options
.
disableCmd
)
...
@@ -376,8 +377,7 @@ int main(int argc, char **argv)
...
@@ -376,8 +377,7 @@ int main(int argc, char **argv)
g_cliRespTask
->
start
();
g_cliRespTask
->
start
();
}
}
for
(
auto
&
ue
:
g_ueMap
)
g_ueMap
.
invokeForeach
([](
const
auto
&
ue
)
{
ue
.
second
->
start
();
});
ue
.
second
->
start
();
while
(
true
)
while
(
true
)
Loop
();
Loop
();
...
...
src/utils/concurrent_map.cpp
0 → 100644
View file @
d9bfa152
//
// 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 "concurrent_map.hpp"
src/utils/concurrent_map.hpp
0 → 100644
View file @
d9bfa152
//
// 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 <mutex>
#include <unordered_map>
#pragma once
template
<
typename
TKey
,
typename
TValue
>
class
ConcurrentMap
{
private:
mutable
std
::
recursive_mutex
m_mutex
{};
std
::
unordered_map
<
TKey
,
TValue
>
m_map
{};
public:
ConcurrentMap
()
=
default
;
public:
TValue
getOrDefault
(
const
TKey
&
key
)
{
std
::
lock_guard
lk
(
m_mutex
);
if
(
m_map
.
count
(
key
)
!=
0
)
return
m_map
[
key
];
return
TValue
{};
}
void
put
(
const
TKey
&
key
,
const
TValue
&
value
)
{
std
::
lock_guard
lk
(
m_mutex
);
m_map
[
key
]
=
value
;
}
template
<
typename
Fun
>
void
invokeForeach
(
const
Fun
&
fun
)
const
{
std
::
lock_guard
lk
(
m_mutex
);
for
(
auto
i
:
m_map
)
fun
(
i
);
}
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment