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
Clearly state that we don't care about the return code of actors
[simgrid.git]
/
examples
/
s4u
/
dht-kademlia
/
s4u-dht-kademlia.cpp
diff --git
a/examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp
b/examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp
index
cd70443
..
ac5231c
100644
(file)
--- a/
examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp
+++ b/
examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp
@@
-1,4
+1,4
@@
-/* Copyright (c) 2012-20
19
. The SimGrid Team.
+/* Copyright (c) 2012-20
20
. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
@@
-17,54
+17,54
@@
XBT_LOG_NEW_DEFAULT_CATEGORY(kademlia, "Messages specific for this example");
* @param the ID of the person I know in the system (or not)
* @param Time before I leave the system because I'm bored
*/
* @param the ID of the person I know in the system (or not)
* @param Time before I leave the system because I'm bored
*/
-static
int
node(int argc, char* argv[])
+static
void
node(int argc, char* argv[])
{
bool join_success = true;
double deadline;
xbt_assert(argc == 3 || argc == 4, "Wrong number of arguments");
/* Node initialization */
unsigned int node_id = strtoul(argv[1], nullptr, 0);
{
bool join_success = true;
double deadline;
xbt_assert(argc == 3 || argc == 4, "Wrong number of arguments");
/* Node initialization */
unsigned int node_id = strtoul(argv[1], nullptr, 0);
- kademlia::Node
* node = new kademlia::N
ode(node_id);
+ kademlia::Node
n
ode(node_id);
if (argc == 4) {
if (argc == 4) {
- XBT_INFO("Hi, I'm going to join the network with id %u", node
->
getId());
+ XBT_INFO("Hi, I'm going to join the network with id %u", node
.
getId());
unsigned int known_id = strtoul(argv[2], NULL, 0);
unsigned int known_id = strtoul(argv[2], NULL, 0);
- join_success = node
->
join(known_id);
+ join_success = node
.
join(known_id);
deadline = std::stod(argv[3]);
} else {
deadline = std::stod(argv[2]);
deadline = std::stod(argv[3]);
} else {
deadline = std::stod(argv[2]);
- XBT_INFO("Hi, I'm going to create the network with id %u", node
->
getId());
- node
->routingTableUpdate(node->
getId());
+ XBT_INFO("Hi, I'm going to create the network with id %u", node
.
getId());
+ node
.routingTableUpdate(node.
getId());
}
if (join_success) {
}
if (join_success) {
- XBT_VERB("Ok, I'm joining the network with id %u", node
->
getId());
+ XBT_VERB("Ok, I'm joining the network with id %u", node
.
getId());
// We start the main loop
// We start the main loop
- double next_lookup_time = simgrid::s4u::Engine::get_clock() +
random_lookup_interval
;
+ double next_lookup_time = simgrid::s4u::Engine::get_clock() +
RANDOM_LOOKUP_INTERVAL
;
XBT_VERB("Main loop start");
XBT_VERB("Main loop start");
- simgrid::s4u::Mailbox
Ptr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(node->
getId()));
+ simgrid::s4u::Mailbox
* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(node.
getId()));
while (simgrid::s4u::Engine::get_clock() < deadline) {
while (simgrid::s4u::Engine::get_clock() < deadline) {
- if (node
->
receive_comm == nullptr)
- node
->receive_comm = mailbox->get_async(&node->
received_msg);
+ if (node
.
receive_comm == nullptr)
+ node
.receive_comm = mailbox->get_async(&node.
received_msg);
- if (node
->
receive_comm->test()) {
+ if (node
.
receive_comm->test()) {
// There has been a message, we need to handle it !
// There has been a message, we need to handle it !
-
kademlia::Message* msg = static_cast<kademlia::Message*>(node->
received_msg);
+
const kademlia::Message* msg = static_cast<kademlia::Message*>(node.
received_msg);
if (msg) {
if (msg) {
- node
->
handleFindNode(msg);
+ node
.
handleFindNode(msg);
delete msg->answer_;
delete msg;
delete msg->answer_;
delete msg;
- node
->
receive_comm = nullptr;
+ node
.
receive_comm = nullptr;
} else
simgrid::s4u::this_actor::sleep_for(1);
} else {
/* We search for a pseudo random node */
if (simgrid::s4u::Engine::get_clock() >= next_lookup_time) {
} else
simgrid::s4u::this_actor::sleep_for(1);
} else {
/* We search for a pseudo random node */
if (simgrid::s4u::Engine::get_clock() >= next_lookup_time) {
- node
->
randomLookup();
- next_lookup_time +=
random_lookup_interval
;
+ node
.
randomLookup();
+ next_lookup_time +=
RANDOM_LOOKUP_INTERVAL
;
} else {
// Didn't get a message: sleep for a while...
simgrid::s4u::this_actor::sleep_for(1);
} else {
// Didn't get a message: sleep for a while...
simgrid::s4u::this_actor::sleep_for(1);
@@
-75,10
+75,7
@@
static int node(int argc, char* argv[])
XBT_INFO("I couldn't join the network :(");
}
XBT_DEBUG("I'm leaving the network");
XBT_INFO("I couldn't join the network :(");
}
XBT_DEBUG("I'm leaving the network");
- XBT_INFO("%u/%u FIND_NODE have succeeded", node->find_node_success, node->find_node_success + node->find_node_failed);
- delete node;
-
- return 0;
+ XBT_INFO("%u/%u FIND_NODE have succeeded", node.find_node_success, node.find_node_success + node.find_node_failed);
}
/** @brief Main function */
}
/** @brief Main function */