Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'xbt_random' into 'master'
[simgrid.git] / examples / s4u / app-bittorrent / s4u-tracker.cpp
index f51e55d..c4bfc16 100644 (file)
@@ -6,7 +6,6 @@
 
 #include "s4u-tracker.hpp"
 #include <algorithm>
-#include <xbt/RngStream.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_bt_tracker, "Messages specific for the tracker");
 
@@ -17,13 +16,11 @@ Tracker::Tracker(std::vector<std::string> args)
   // Retrieving end time
   try {
     deadline = std::stod(args[1]);
-  } catch (std::invalid_argument& ia) {
-    throw std::invalid_argument(std::string("Invalid deadline:") + args[1].c_str());
+  } catch (const std::invalid_argument&) {
+    throw std::invalid_argument("Invalid deadline:" + args[1]);
   }
   xbt_assert(deadline > 0, "Wrong deadline supplied");
 
-  stream = simgrid::s4u::this_actor::get_host()->extension<HostBittorrent>()->getStream();
-
   mailbox = simgrid::s4u::Mailbox::by_name(TRACKER_MAILBOX);
 
   XBT_INFO("Tracker launched.");
@@ -55,7 +52,7 @@ void Tracker::operator()()
       while (tried < max_tries) {
         do {
           next_peer = known_peers.begin();
-          std::advance(next_peer, RngStream_RandInt(stream, 0, nb_known_peers - 1));
+          std::advance(next_peer, simgrid::xbt::random::uniform_int(0, nb_known_peers - 1));
         } while (ta->getPeers().find(*next_peer) != ta->getPeers().end());
         ta->addPeer(*next_peer);
         tried++;