Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use C++17 features: std::scoped_lock and structured bindings.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 23 May 2023 12:33:54 +0000 (14:33 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 23 May 2023 13:08:03 +0000 (15:08 +0200)
include/simgrid/plugins/ProducerConsumer.hpp
include/xbt/config.hpp
include/xbt/signal.hpp

index 44e2f27..87d4cfa 100644 (file)
@@ -103,7 +103,7 @@ public:
    */
   ProducerConsumer* set_max_queue_size(unsigned int max_queue_size)
   {
-    const std::lock_guard<s4u::Mutex> lock(*mutex_);
+    const std::scoped_lock lock(*mutex_);
     max_queue_size_ = max_queue_size;
     return this;
   }
index 589c8dc..bb5ee91 100644 (file)
@@ -173,8 +173,8 @@ bind_flag(std::string& value, const char* name, const char* description,
                    mesg += std::string("Possible values for option ") + name + ":\n";
                  else
                    mesg += "Invalid value '" + val + "' for option " + name + ". Possible values:\n";
-                 for (auto const& kv : valid_values)
-                   mesg += "  - '" + kv.first + "': " + kv.second + (kv.first == value ? "  <=== DEFAULT" : "") + "\n";
+                 for (auto const& [v, descr] : valid_values)
+                   mesg += "  - '" + v + "': " + descr + (v == value ? "  <=== DEFAULT" : "") + "\n";
                  xbt_die("%s", mesg.c_str());
                }));
 }
index 26694c3..70c477f 100644 (file)
@@ -34,8 +34,8 @@ public:
   /** Fire that signal, invoking all callbacks */
   R operator()(P... args) const
   {
-    for (auto const& handler : handlers_)
-      handler.second(args...);
+    for (auto const& [_, callback] : handlers_)
+      callback(args...);
   }
   /** Remove a callback */
   void disconnect(unsigned int id) { handlers_.erase(id); }