Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
another try at cleanly unlocking the mutexes before destroying them in SMPI::RMA
[simgrid.git] / examples / cpp / exec-failure / s4u-exec-failure.cpp
index 1dd509a9410bfbb3f87ab49a4ab08a5178a75b9e..4a4063bda6e8c0a85563e2d2c973dfe331d8c6c2 100644 (file)
@@ -3,16 +3,13 @@
 /* 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. */
 
-/* This example shows how to serialize a set of communications going through a link
+/* This examples shows how to survive to host failure exceptions that occur when an host is turned off.
  *
- * As for the other asynchronous examples, the sender initiates all the messages it wants to send and
- * pack the resulting simgrid::s4u::CommPtr objects in a vector.
- * At the same time, the receiver starts receiving all messages asynchronously. Without serialization,
- * all messages would be received at the same timestamp in the receiver.
+ * The actors do not get notified when the host on which they run is turned off: they are just terminated
+ * in this case, and their ``on_exit()`` callback gets executed.
  *
- * However, as they will be serialized in a link of the platform, the messages arrive 2 by 2.
- *
- * The sender then blocks until all ongoing communication terminate, using simgrid::s4u::Comm::wait_all()
+ * For remote executions on failing hosts however, any blocking operation such as ``exec`` or ``wait`` will
+ * raise an exception that you can catch and react to, as illustrated in this example.
  */
 
 #include <simgrid/s4u.hpp>
@@ -83,7 +80,7 @@ int main(int argc, char** argv)
 
   auto* zone  = sg4::create_full_zone("world");
   std::vector<sg4::Host*> hosts;
-  for (auto name : {"Host1", "Host2", "Host3"}) {
+  for (const auto* name : {"Host1", "Host2", "Host3"}) {
     auto* host = zone->create_host(name, "1f");
     hosts.push_back(host);
   }