A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Reduce scope for static variables.
[simgrid.git]
/
src
/
surf
/
network_ns3.cpp
diff --git
a/src/surf/network_ns3.cpp
b/src/surf/network_ns3.cpp
index
3fbd4ca
..
a3ad27a
100644
(file)
--- a/
src/surf/network_ns3.cpp
+++ b/
src/surf/network_ns3.cpp
@@
-412,10
+412,7
@@
void NetworkNS3Model::update_actions_state(double now, double delta)
{
static std::vector<std::string> socket_to_destroy;
- std::string ns3_socket;
- for (const auto& elm : flow_from_sock) {
- ns3_socket = elm.first;
- SgFlow* sgFlow = elm.second;
+ for (const auto& [ns3_socket, sgFlow] : flow_from_sock) {
NetworkNS3Action* action = sgFlow->action_;
XBT_DEBUG("Processing flow %p (socket %s, action %p)", sgFlow, ns3_socket.c_str(), action);
// Because NS3 stops as soon as a flow is finished, the other flows that ends at the same time may remains in an
@@
-451,7
+448,7
@@
void NetworkNS3Model::update_actions_state(double now, double delta)
}
while (not socket_to_destroy.empty()) {
- ns3_socket = socket_to_destroy.back();
+
std::string
ns3_socket = socket_to_destroy.back();
socket_to_destroy.pop_back();
SgFlow* flow = flow_from_sock.at(ns3_socket);
if (XBT_LOG_ISENABLED(res_ns3, xbt_log_priority_debug)) {
@@
-508,8
+505,7
@@
NetworkNS3Action::NetworkNS3Action(Model* model, double totalBytes, s4u::Host* s
// ns-3 fails when src = dst, so avoid the problem by considering that communications are infinitely fast on the
// loopback that does not exists
if (src == dst) {
- static bool warned = false;
- if (not warned) {
+ if (static bool warned = false; not warned) {
XBT_WARN("Sending from a host %s to itself is not supported by ns-3. Every such communication finishes "
"immediately upon startup.",
src->get_cname());
@@
-545,8
+541,8
@@
NetworkNS3Action::NetworkNS3Action(Model* model, double totalBytes, s4u::Host* s
XBT_DEBUG("Create socket %s for a flow of %.0f Bytes from %s to %s with Interface %s",
transform_socket_ptr(sock).c_str(), totalBytes, src->get_cname(), dst->get_cname(), addr.c_str());
- flow_from_sock.
insert({transform_socket_ptr(sock), new SgFlow(static_cast<uint32_t>(totalBytes), this)}
);
- sink_from_sock.
insert({transform_socket_ptr(sock), apps}
);
+ flow_from_sock.
try_emplace(transform_socket_ptr(sock), new SgFlow(static_cast<uint32_t>(totalBytes), this)
);
+ sink_from_sock.
try_emplace(transform_socket_ptr(sock), apps
);
sock->Bind(ns3::InetSocketAddress(port_number));
ns3::Simulator::ScheduleNow(&start_flow, sock, addr.c_str(), port_number);