Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Removing RngStream
[simgrid.git] / examples / s4u / app-bittorrent / s4u-bittorrent.hpp
index 19551d0..0895354 100644 (file)
@@ -7,8 +7,8 @@
 #ifndef BITTORRENT_BITTORRENT_HPP_
 #define BITTORRENT_BITTORRENT_HPP_
 
+#include <random>
 #include <simgrid/s4u.hpp>
-#include <xbt/RngStream.h>
 
 constexpr char TRACKER_MAILBOX[] = "tracker_mailbox";
 /** Max number of peers sent by the tracker to clients */
@@ -75,27 +75,17 @@ public:
       , block_length(block_length){};
   Message(e_message_type type, int peer_id, simgrid::s4u::Mailbox* return_mailbox, int piece)
       : type(type), peer_id(peer_id), return_mailbox(return_mailbox), piece(piece){};
-  ~Message() = default;
 };
 
 class HostBittorrent {
-  RngStream stream_;
   simgrid::s4u::Host* host = nullptr;
 
 public:
-  static simgrid::xbt::Extension<simgrid::s4u::Host, HostBittorrent> EXTENSION_ID;
-
-  explicit HostBittorrent(simgrid::s4u::Host* ptr) : host(ptr)
-  {
-    std::string descr = std::string("RngSream<") + host->get_cname() + ">";
-    stream_           = RngStream_CreateStream(descr.c_str());
-  }
+  explicit HostBittorrent(simgrid::s4u::Host* ptr) : host(ptr) {}
   HostBittorrent(const HostBittorrent&) = delete;
   HostBittorrent& operator=(const HostBittorrent&) = delete;
-
-  ~HostBittorrent() { RngStream_DeleteStream(&stream_); };
-
-  RngStream getStream() { return stream_; };
 };
 
+extern std::default_random_engine generator;
+
 #endif /* BITTORRENT_BITTORRENT_HPP_ */