Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 31 Aug 2021 07:55:56 +0000 (09:55 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 31 Aug 2021 07:56:02 +0000 (09:56 +0200)
examples/cpp/comm-failure/s4u-comm-failure.cpp
examples/cpp/exec-failure/s4u-exec-failure.cpp
examples/cpp/exec-remote/s4u-exec-remote.cpp

index ac12fd3..5561f81 100644 (file)
@@ -25,12 +25,12 @@ class Sender {
   std::string mailbox2_name;
 
 public:
-  Sender(std::string mailbox1_name, std::string mailbox2_name)
+  Sender(const std::string& mailbox1_name, const std::string& mailbox2_name)
       : mailbox1_name(mailbox1_name), mailbox2_name(mailbox2_name)
   {
   }
 
-  void operator()()
+  void operator()() const
   {
     auto mailbox1 = sg4::Mailbox::by_name(mailbox1_name);
     auto mailbox2 = sg4::Mailbox::by_name(mailbox2_name);
@@ -47,7 +47,7 @@ public:
     try {
       long index = sg4::Comm::wait_any(pending_comms);
       XBT_INFO("Wait any returned index %ld (comm to %s)", index, pending_comms.at(index)->get_mailbox()->get_cname());
-    } catch (simgrid::NetworkFailureException& e) {
+    } catch (const simgrid::NetworkFailureException&) {
       XBT_INFO("Sender has experienced a network failure exception, so it knows that something went wrong");
       XBT_INFO("Now it needs to figure out which of the two comms failed by looking at their state");
     }
@@ -57,7 +57,7 @@ public:
 
     try {
       comm1->wait();
-    } catch (simgrid::NetworkFailureException& e) {
+    } catch (const simgrid::NetworkFailureException& e) {
       XBT_INFO("Waiting on a FAILED comm raises an exception: '%s'", e.what());
     }
     XBT_INFO("Wait for remaining comm, just to be nice");
@@ -70,9 +70,9 @@ class Receiver {
   std::string mailbox_name;
 
 public:
-  explicit Receiver(std::string mailbox_name) : mailbox_name(mailbox_name) {}
+  explicit Receiver(const std::string& mailbox_name) : mailbox_name(mailbox_name) {}
 
-  void operator()()
+  void operator()() const
   {
     auto mailbox = sg4::Mailbox::by_name(mailbox_name);
     XBT_INFO("Receiver posting a receive...");
@@ -89,9 +89,9 @@ class LinkKiller {
   std::string link_name;
 
 public:
-  explicit LinkKiller(std::string link_name) : link_name(link_name) {}
+  explicit LinkKiller(const std::string& link_name) : link_name(link_name) {}
 
-  void operator()()
+  void operator()() const
   {
     auto link_to_kill = sg4::Link::by_name(link_name);
     XBT_INFO("LinkKiller  sleeping 10 seconds...");
index 9d5d1ad..ec44739 100644 (file)
@@ -36,7 +36,7 @@ static void dispatcher(sg4::Host* host1, sg4::Host* host2)
   try {
     long index = sg4::Exec::wait_any(pending_execs);
     XBT_INFO("Wait any returned index %ld (exec on %s)", index, pending_execs.at(index)->get_host()->get_cname());
-  } catch (simgrid::HostFailureException& e) {
+  } catch (const simgrid::HostFailureException&) {
     XBT_INFO("Dispatcher has experienced a host failure exception, so it knows that something went wrong");
     XBT_INFO("Now it needs to figure out which of the two execs failed by looking at their state");
   }
@@ -46,7 +46,7 @@ static void dispatcher(sg4::Host* host1, sg4::Host* host2)
 
   try {
     pending_execs[1]->wait();
-  } catch (simgrid::HostFailureException& e) {
+  } catch (const simgrid::HostFailureException& e) {
     XBT_INFO("Waiting on a FAILED exec raises an exception: '%s'", e.what());
   }
   pending_execs.pop_back();
index aa6d80b..6a7dde7 100644 (file)
@@ -51,7 +51,7 @@ static void wizard()
   ginette->turn_off();
   try {
     exec->wait();
-  } catch (const simgrid::HostFailureException& e) {
+  } catch (const simgrid::HostFailureException&) {
     XBT_INFO("Execution failed on %s", ginette->get_cname());
   }
   XBT_INFO("Done!");