Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Try to ensure test reproducibility.
[simgrid.git] / examples / s4u / dht-chord / s4u-dht-chord.hpp
index ba0ac1f..81821cf 100644 (file)
@@ -6,8 +6,8 @@
 #ifndef S4U_CHORD_HPP
 #define S4U_CHORD_HPP
 #include "simgrid/s4u.hpp"
+#include <random>
 #include <string>
-#include <xbt/RngStream.h>
 #include <xbt/str.h>
 
 constexpr double MAX_SIMULATION_TIME              = 1000;
@@ -21,25 +21,7 @@ extern int nb_bits;
 extern int nb_keys;
 extern int timeout;
 
-class HostChord {
-  RngStream stream_;
-  simgrid::s4u::Host* host = nullptr;
-
-public:
-  static simgrid::xbt::Extension<simgrid::s4u::Host, HostChord> EXTENSION_ID;
-
-  explicit HostChord(simgrid::s4u::Host* ptr) : host(ptr)
-  {
-    std::string descr = std::string("RngSream<") + host->get_cname() + ">";
-    stream_           = RngStream_CreateStream(descr.c_str());
-  }
-  HostChord(const HostChord&) = delete;
-  HostChord& operator=(const HostChord&) = delete;
-
-  ~HostChord() { RngStream_DeleteStream(&stream_); };
-
-  RngStream getStream() { return stream_; };
-};
+extern std::mt19937 generator;
 
 /* Types of tasks exchanged between nodes. */
 enum e_message_type_t {
@@ -68,8 +50,6 @@ public:
   {
   }
 
-  ~ChordMessage() = default;
-
   static void destroy(void* message);
 };
 
@@ -81,15 +61,13 @@ class Node {
   int id_;                           // my id
   int pred_id_ = -1;                 // predecessor id
   simgrid::s4u::Mailbox* mailbox_;   // my mailbox
-  int* fingers_;                     // finger table,(fingers[0] is my successor)
+  std::vector<int> fingers_;         // finger table,(fingers[0] is my successor)
   int next_finger_to_fix;            // index of the next finger to fix in fix_fingers()
-  RngStream stream;
 
 public:
   explicit Node(std::vector<std::string> args);
   Node(const Node&) = delete;
   Node& operator=(const Node&) = delete;
-  ~Node();
   void join(int known_id);
   void leave();
   void notifyAndQuit();