Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Remove useless commented lines of code.
[simgrid.git] / examples / s4u / app-bittorrent / s4u-peer.hpp
index 9d1e195..2737649 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017. The SimGrid Team.
+/* Copyright (c) 2012-2019. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -13,9 +13,8 @@
 class Connection {
 public:
   int id; // Peer id
-  simgrid::s4u::MailboxPtr mailbox_;
+  simgrid::s4u::Mailbox* mailbox_;
   unsigned int bitfield = 0U; // Fields
-  //  int messages_count;
   double peer_speed    = 0;
   double last_unchoke  = 0;
   int current_piece    = -1;
@@ -24,7 +23,7 @@ public:
   bool choked_upload   = true;  // Indicates if the peer is choked for the current peer
   bool choked_download = true;  // Indicates if the peer has choked the current peer
 
-  explicit Connection(int id) : id(id), mailbox_(simgrid::s4u::Mailbox::byName(std::to_string(id))){};
+  explicit Connection(int id) : id(id), mailbox_(simgrid::s4u::Mailbox::by_name(std::to_string(id))){};
   ~Connection() = default;
   void addSpeedValue(double speed) { peer_speed = peer_speed * 0.6 + speed * 0.4; }
   bool hasPiece(unsigned int piece) { return bitfield & 1U << piece; }
@@ -34,7 +33,7 @@ class Peer {
   int id;
   double deadline;
   RngStream stream;
-  simgrid::s4u::MailboxPtr mailbox_;
+  simgrid::s4u::Mailbox* mailbox_;
   std::unordered_map<int, Connection*> connected_peers;
   std::set<Connection*> active_peers; // active peers list
 
@@ -50,6 +49,7 @@ class Peer {
 public:
   explicit Peer(std::vector<std::string> args);
   Peer(const Peer&) = delete;
+  Peer& operator=(const Peer&) = delete;
   ~Peer();
   void operator()();
 
@@ -76,9 +76,9 @@ public:
   void requestNewPieceTo(Connection* remote_peer);
 
   bool getPeersFromTracker();
-  void sendMessage(simgrid::s4u::MailboxPtr mailbox, e_message_type type, uint64_t size);
-  void sendBitfield(simgrid::s4u::MailboxPtr mailbox);
-  void sendPiece(simgrid::s4u::MailboxPtr mailbox, unsigned int piece, int block_index, int block_length);
+  void sendMessage(simgrid::s4u::Mailbox* mailbox, e_message_type type, uint64_t size);
+  void sendBitfield(simgrid::s4u::Mailbox* mailbox);
+  void sendPiece(simgrid::s4u::Mailbox* mailbox, unsigned int piece, int block_index, int block_length);
   void sendHandshakeToAllPeers();
   void sendHaveToAllPeers(unsigned int piece);
   void sendRequestTo(Connection* remote_peer, unsigned int piece);