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
Update .mailmap.
[simgrid.git]
/
examples
/
cpp
/
dht-kademlia
/
s4u-dht-kademlia.cpp
diff --git
a/examples/cpp/dht-kademlia/s4u-dht-kademlia.cpp
b/examples/cpp/dht-kademlia/s4u-dht-kademlia.cpp
index 828fae8d8e035951f7cbec82ab8c060c6bc50d69..c9a90625413e29817d8a78084adee4bc562278df 100644
(file)
--- a/
examples/cpp/dht-kademlia/s4u-dht-kademlia.cpp
+++ b/
examples/cpp/dht-kademlia/s4u-dht-kademlia.cpp
@@
-1,5
+1,4
@@
-/* Copyright (c) 2012-2021. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2023. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
@@
-11,6
+10,7
@@
#include "simgrid/s4u.hpp"
XBT_LOG_NEW_DEFAULT_CATEGORY(kademlia, "Messages specific for this example");
#include "simgrid/s4u.hpp"
XBT_LOG_NEW_DEFAULT_CATEGORY(kademlia, "Messages specific for this example");
+namespace sg4 = simgrid::s4u;
/** @brief Node function
* @param my node ID
/** @brief Node function
* @param my node ID
@@
-40,32
+40,25
@@
static void node(std::vector<std::string> args)
if (join_success) {
XBT_VERB("Ok, I'm joining the network with id %u", node.getId());
// We start the main loop
if (join_success) {
XBT_VERB("Ok, I'm joining the network with id %u", node.getId());
// We start the main loop
- double next_lookup_time = s
imgrid::s4u
::Engine::get_clock() + RANDOM_LOOKUP_INTERVAL;
+ double next_lookup_time = s
g4
::Engine::get_clock() + RANDOM_LOOKUP_INTERVAL;
XBT_VERB("Main loop start");
XBT_VERB("Main loop start");
- s
imgrid::s4u::Mailbox* mailbox = simgrid::s4u
::Mailbox::by_name(std::to_string(node.getId()));
+ s
g4::Mailbox* mailbox = sg4
::Mailbox::by_name(std::to_string(node.getId()));
- while (simgrid::s4u::Engine::get_clock() < deadline) {
- if (node.receive_comm == nullptr)
- node.receive_comm = mailbox->get_async<kademlia::Message>(&node.received_msg);
-
- if (node.receive_comm->test()) {
+ while (sg4::Engine::get_clock() < deadline) {
+ if (kademlia::Message* msg = node.receive(mailbox)) {
// There has been a message, we need to handle it !
// There has been a message, we need to handle it !
- if (node.received_msg) {
- node.handleFindNode(node.received_msg);
- delete node.received_msg;
- node.receive_comm = nullptr;
- } else
- simgrid::s4u::this_actor::sleep_for(1);
+ node.handleFindNode(msg);
+ delete msg;
} else {
/* We search for a pseudo random node */
} else {
/* We search for a pseudo random node */
- if (s
imgrid::s4u
::Engine::get_clock() >= next_lookup_time) {
+ if (s
g4
::Engine::get_clock() >= next_lookup_time) {
node.randomLookup();
next_lookup_time += RANDOM_LOOKUP_INTERVAL;
} else {
// Didn't get a message: sleep for a while...
node.randomLookup();
next_lookup_time += RANDOM_LOOKUP_INTERVAL;
} else {
// Didn't get a message: sleep for a while...
- s
imgrid::s4u
::this_actor::sleep_for(1);
+ s
g4
::this_actor::sleep_for(1);
}
}
}
}
}
}
@@
-79,7
+72,7
@@
static void node(std::vector<std::string> args)
/** @brief Main function */
int main(int argc, char* argv[])
{
/** @brief Main function */
int main(int argc, char* argv[])
{
- s
imgrid::s4u
::Engine e(&argc, argv);
+ s
g4
::Engine e(&argc, argv);
/* Check the arguments */
xbt_assert(argc > 2,
/* Check the arguments */
xbt_assert(argc > 2,
@@
-92,7
+85,7
@@
int main(int argc, char* argv[])
e.run();
e.run();
- XBT_INFO("Simulated time: %g", s
imgrid::s4u
::Engine::get_clock());
+ XBT_INFO("Simulated time: %g", s
g4
::Engine::get_clock());
return 0;
}
return 0;
}