Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The dht-chord example now uses the new module
authorYann Duplouy <yann.duplouy@inria.fr>
Mon, 21 Oct 2019 09:18:37 +0000 (11:18 +0200)
committerYann Duplouy <yann.duplouy@inria.fr>
Mon, 21 Oct 2019 09:18:37 +0000 (11:18 +0200)
examples/s4u/dht-chord/s4u-dht-chord-node.cpp
examples/s4u/dht-chord/s4u-dht-chord.cpp
examples/s4u/dht-chord/s4u-dht-chord.hpp

index 8d9640f..f76484c 100644 (file)
@@ -134,9 +134,7 @@ void Node::notifyAndQuit()
 void Node::randomLookup()
 {
   int res          = id_;
-  // std::uniform_int_distribution<int> dist(0, nb_bits - 1);
-  // int random_index = dist(generator);
-  int random_index = generator() % nb_bits; // ensure reproducibility across platforms
+  int random_index = simgrid::xbt::random::uniform_int(0, nb_bits - 1);
   int random_id    = fingers_[random_index];
   XBT_DEBUG("Making a lookup request for id %d", random_id);
   if (random_id != id_)
index b8d20a7..372c509 100644 (file)
@@ -11,8 +11,6 @@ int nb_bits  = 24;
 int nb_keys  = 0;
 int timeout  = 50;
 
-std::mt19937 generator;
-
 int main(int argc, char* argv[])
 {
   simgrid::s4u::Engine e(&argc, argv);
index 81821cf..eea1f2f 100644 (file)
@@ -6,8 +6,8 @@
 #ifndef S4U_CHORD_HPP
 #define S4U_CHORD_HPP
 #include "simgrid/s4u.hpp"
-#include <random>
 #include <string>
+#include <xbt/random.hpp>
 #include <xbt/str.h>
 
 constexpr double MAX_SIMULATION_TIME              = 1000;
@@ -21,8 +21,6 @@ extern int nb_bits;
 extern int nb_keys;
 extern int timeout;
 
-extern std::mt19937 generator;
-
 /* Types of tasks exchanged between nodes. */
 enum e_message_type_t {
   FIND_SUCCESSOR,