Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill useless array powers2 and simplify code.
[simgrid.git] / examples / s4u / dht-chord / s4u-dht-chord-node.cpp
index 9cc987f..d7ab98a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -52,7 +52,7 @@ Node::Node(std::vector<std::string> args)
 
   // initialize my node
   id_                = std::stoi(args[1]);
-  stream             = simgrid::s4u::this_actor::getHost()->extension<HostChord>()->getStream();
+  stream             = simgrid::s4u::this_actor::get_host()->extension<HostChord>()->getStream();
   mailbox_           = simgrid::s4u::Mailbox::byName(std::to_string(id_));
   next_finger_to_fix = 0;
   fingers_           = new int[nb_bits];
@@ -63,7 +63,7 @@ Node::Node(std::vector<std::string> args)
 
   if (args.size() == 3) { // first ring
     deadline_   = std::stod(args[2]);
-    start_time_ = simgrid::s4u::Engine::getClock();
+    start_time_ = simgrid::s4u::Engine::get_clock();
     XBT_DEBUG("Create a new Chord ring...");
   } else {
     known_id_   = std::stoi(args[2]);
@@ -184,7 +184,7 @@ void Node::setPredecessor(int predecessor_id)
 void Node::fixFingers()
 {
   XBT_DEBUG("Fixing fingers");
-  int id = findSuccessor(id_ + powers2[next_finger_to_fix]);
+  int id = findSuccessor(id_ + (1U << next_finger_to_fix));
   if (id != -1) {
     if (id != fingers_[next_finger_to_fix]) {
       setFinger(next_finger_to_fix, id);
@@ -201,7 +201,7 @@ void Node::printFingerTable()
     XBT_VERB("My finger table:");
     XBT_VERB("Start | Succ");
     for (int i = 0; i < nb_bits; i++) {
-      XBT_VERB(" %3d  | %3d", (id_ + powers2[i]) % nb_keys, fingers_[i]);
+      XBT_VERB(" %3u  | %3d", (id_ + (1U << i)) % nb_keys, fingers_[i]);
     }
 
     XBT_VERB("Predecessor: %d", pred_id_);