Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
snake case this bool
[simgrid.git] / include / simgrid / s4u / Actor.hpp
index d0a0086..7e5c4f1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2019. 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. */
@@ -126,7 +126,7 @@ class XBT_PUBLIC Actor : public simgrid::xbt::Extendable<Actor> {
   friend simgrid::kernel::actor::ActorImpl;
   friend simgrid::kernel::activity::MailboxImpl;
 
-  kernel::actor::ActorImpl* pimpl_ = nullptr;
+  kernel::actor::ActorImpl* const pimpl_ = nullptr;
 
   explicit Actor(smx_actor_t pimpl) : pimpl_(pimpl) {}
 
@@ -176,7 +176,7 @@ public:
    */
   template <class F> static ActorPtr create(std::string name, s4u::Host* host, F code)
   {
-    return create(name, host, std::function<void()>(std::move(code)));
+    return create(std::move(name), host, std::function<void()>(std::move(code)));
   }
 
   /** Create an actor using a callable thing and its arguments.
@@ -187,11 +187,11 @@ public:
             typename = typename std::result_of<F(Args...)>::type>
   static ActorPtr create(std::string name, s4u::Host* host, F code, Args... args)
   {
-    return create(name, host, std::bind(std::move(code), std::move(args)...));
+    return create(std::move(name), host, std::bind(std::move(code), std::move(args)...));
   }
 
   // Create actor from function name:
-  static ActorPtr create(std::string name, s4u::Host* host, std::string function, std::vector<std::string> args);
+  static ActorPtr create(std::string name, s4u::Host* host, const std::string& function, std::vector<std::string> args);
 
   // ***** Methods *****
   /** This actor will be automatically terminated when the last non-daemon actor finishes **/
@@ -258,9 +258,6 @@ public:
    */
   void kill();
 
-  /** Kill an actor from its ID */
-  static void kill(aid_t pid);
-
   /** Retrieves the actor that have the given PID (or nullptr if not existing) */
   static ActorPtr by_pid(aid_t pid);
 
@@ -279,7 +276,7 @@ public:
   void join(double timeout);
   Actor* restart();
 
-  /** Ask kindly to all actors to die. Only the issuer will survive. */
+  /** Kill all actors (but the issuer). Being killed is not something that actors can delay or avoid. */
   static void kill_all();
 
   /** Returns the internal implementation of this actor */
@@ -288,10 +285,12 @@ public:
   /** Retrieve the property value (or nullptr if not set) */
   std::unordered_map<std::string, std::string>*
   get_properties(); // FIXME: do not export the map, but only the keys or something
-  const char* get_property(std::string key);
-  void set_property(std::string key, std::string value);
+  const char* get_property(const std::string& key);
+  void set_property(const std::string& key, std::string value);
 
 #ifndef DOXYGEN
+  XBT_ATTRIB_DEPRECATED_v325("Please use Actor::by_pid(pid).kill() instead") static void kill(aid_t pid);
+
   /** @deprecated See Actor::create() */
   XBT_ATTRIB_DEPRECATED_v323("Please use Actor::create()") static ActorPtr createActor(
       const char* name, s4u::Host* host, std::function<void()> code)
@@ -470,22 +469,23 @@ XBT_PUBLIC void execute(double flop, double priority);
  *
  * \endrst
  */
-XBT_PUBLIC void parallel_execute(std::vector<s4u::Host*> hosts, std::vector<double> flops_amounts,
-                                 std::vector<double> bytes_amounts);
+XBT_PUBLIC void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
+                                 const std::vector<double>& bytes_amounts);
 
 /** \rst
  * Block the current actor until the built :ref:`parallel execution <API_s4u_parallel_execute>` completes, or until the
  * timeout. \endrst
  */
-XBT_PUBLIC void parallel_execute(std::vector<s4u::Host*> hosts, std::vector<double> flops_amounts,
-                                 std::vector<double> bytes_amounts, double timeout);
+XBT_PUBLIC void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
+                                 const std::vector<double>& bytes_amounts, double timeout);
 
 #ifndef DOXYGEN
 XBT_ATTRIB_DEPRECATED_v325("Please use std::vectors as parameters") XBT_PUBLIC
-    void parallel_execute(int host_nb, s4u::Host** host_list, double* flops_amount, double* bytes_amount);
+    void parallel_execute(int host_nb, s4u::Host* const* host_list, const double* flops_amount,
+                          const double* bytes_amount);
 XBT_ATTRIB_DEPRECATED_v325("Please use std::vectors as parameters") XBT_PUBLIC
-    void parallel_execute(int host_nb, s4u::Host** host_list, double* flops_amount, double* bytes_amount,
-                          double timeout);
+    void parallel_execute(int host_nb, s4u::Host* const* host_list, const double* flops_amount,
+                          const double* bytes_amount, double timeout);
 #endif
 
 XBT_PUBLIC ExecPtr exec_init(double flops_amounts);