Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
partially stringify s4u::Actor
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 9 Jul 2018 22:46:14 +0000 (00:46 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 9 Jul 2018 22:46:14 +0000 (00:46 +0200)
include/simgrid/msg.h
include/simgrid/s4u/Actor.hpp
include/simgrid/simix.h
include/simgrid/simix.hpp
src/kernel/context/Context.hpp
src/msg/msg_private.hpp
src/msg/msg_process.cpp
src/s4u/s4u_Actor.cpp
src/simix/ActorImpl.cpp
src/simix/ActorImpl.hpp
src/simix/smx_deployment.cpp

index ea93d1b..66642ef 100644 (file)
@@ -369,7 +369,7 @@ MSG_process_get_smx_ctx(msg_process_t process);
 SG_END_DECL()
 
 #ifdef __cplusplus
 SG_END_DECL()
 
 #ifdef __cplusplus
-XBT_PUBLIC msg_process_t MSG_process_create_from_stdfunc(const char* name, std::function<void()> code, void* data,
+XBT_PUBLIC msg_process_t MSG_process_create_from_stdfunc(std::string name, std::function<void()> code, void* data,
                                                          msg_host_t host,
                                                          std::unordered_map<std::string, std::string>* properties);
 #endif
                                                          msg_host_t host,
                                                          std::unordered_map<std::string, std::string>* properties);
 #endif
index 182289a..65d9bd6 100644 (file)
@@ -173,9 +173,9 @@ public:
    *
    *  If the actor is restarted, the actor has a fresh copy of the function.
    */
    *
    *  If the actor is restarted, the actor has a fresh copy of the function.
    */
-  static ActorPtr create(const char* name, s4u::Host* host, std::function<void()> code);
+  static ActorPtr create(std::string name, s4u::Host* host, std::function<void()> code);
 
 
-  static ActorPtr create(const char* name, s4u::Host* host, std::function<void(std::vector<std::string>*)> code,
+  static ActorPtr create(std::string name, s4u::Host* host, std::function<void(std::vector<std::string>*)> code,
                          std::vector<std::string>* args)
   {
     return create(name, host, [code](std::vector<std::string>* args) { code(args); }, args);
                          std::vector<std::string>* args)
   {
     return create(name, host, [code](std::vector<std::string>* args) { code(args); }, args);
@@ -191,13 +191,13 @@ public:
   template <class F, class... Args,
             // This constructor is enabled only if the call code(args...) is valid:
             typename = typename std::result_of<F(Args...)>::type>
   template <class F, class... Args,
             // This constructor is enabled only if the call code(args...) is valid:
             typename = typename std::result_of<F(Args...)>::type>
-  static ActorPtr create(const char* name, s4u::Host* host, F code, Args... args)
+  static ActorPtr create(std::string name, s4u::Host* host, F code, Args... args)
   {
     return create(name, host, wrap_task(std::move(code), std::move(args)...));
   }
 
   // Create actor from function name:
   {
     return create(name, host, wrap_task(std::move(code), std::move(args)...));
   }
 
   // Create actor from function name:
-  static ActorPtr create(const char* name, s4u::Host* host, const char* function, std::vector<std::string> args);
+  static ActorPtr create(std::string name, s4u::Host* host, std::string function, std::vector<std::string> args);
 
   // ***** Methods *****
   /** This actor will be automatically terminated when the last non-daemon actor finishes **/
 
   // ***** Methods *****
   /** This actor will be automatically terminated when the last non-daemon actor finishes **/
@@ -279,8 +279,8 @@ 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
   /** 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(const char* key);
-  void set_property(const char* key, const char* value);
+  const char* get_property(std::string key);
+  void set_property(std::string key, std::string value);
 
   XBT_ATTRIB_DEPRECATED_v323("Please use Actor::create()") static ActorPtr createActor(
       const char* name, s4u::Host* host, std::function<void()> code)
 
   XBT_ATTRIB_DEPRECATED_v323("Please use Actor::create()") static ActorPtr createActor(
       const char* name, s4u::Host* host, std::function<void()> code)
index 370f11b..1c20d8e 100644 (file)
@@ -186,7 +186,7 @@ XBT_PUBLIC e_smx_state_t simcall_execution_test(smx_activity_t execution);
 SG_BEGIN_DECL()
 /* Constructor and Destructor */
 #ifdef __cplusplus
 SG_BEGIN_DECL()
 /* Constructor and Destructor */
 #ifdef __cplusplus
-XBT_PUBLIC smx_actor_t simcall_process_create(const char* name, xbt_main_func_t code, void* data, sg_host_t host,
+XBT_PUBLIC smx_actor_t simcall_process_create(std::string name, xbt_main_func_t code, void* data, sg_host_t host,
                                               int argc, char** argv,
                                               std::unordered_map<std::string, std::string>* properties);
 #endif
                                               int argc, char** argv,
                                               std::unordered_map<std::string, std::string>* properties);
 #endif
index f227304..a88cf53 100644 (file)
@@ -90,7 +90,7 @@ XBT_PUBLIC void register_function(const char* name, ActorCodeFactory factory);
  * std::map<std::string, std::string>* props: properties
  */
 typedef smx_actor_t (*smx_creation_func_t)(
  * std::map<std::string, std::string>* props: properties
  */
 typedef smx_actor_t (*smx_creation_func_t)(
-    /* name */ const char*, simgrid::simix::ActorCode code,
+    /* name */ std::string, simgrid::simix::ActorCode code,
     /* userdata */ void*,
     /* hostname */ sg_host_t,
     /* props */ std::unordered_map<std::string, std::string>*,
     /* userdata */ void*,
     /* hostname */ sg_host_t,
     /* props */ std::unordered_map<std::string, std::string>*,
@@ -98,8 +98,8 @@ typedef smx_actor_t (*smx_creation_func_t)(
 
 XBT_PUBLIC void SIMIX_function_register_process_create(smx_creation_func_t function);
 
 
 XBT_PUBLIC void SIMIX_function_register_process_create(smx_creation_func_t function);
 
-XBT_PUBLIC smx_actor_t simcall_process_create(const char* name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
-                                              std::unordered_map<std::string, std::string>* properties);
+XBT_PUBLIC smx_actor_t simcall_process_create(std::string name, simgrid::simix::ActorCode code, void* data,
+                                              sg_host_t host, std::unordered_map<std::string, std::string>* properties);
 
 XBT_PUBLIC smx_timer_t SIMIX_timer_set(double date, simgrid::xbt::Task<void()> callback);
 
 
 XBT_PUBLIC smx_timer_t SIMIX_timer_set(double date, simgrid::xbt::Task<void()> callback);
 
index 8fa9747..dd4e482 100644 (file)
@@ -142,6 +142,6 @@ XBT_PUBLIC int SIMIX_process_get_maxpid();
 
 XBT_PRIVATE void SIMIX_post_create_environment();
 
 
 XBT_PRIVATE void SIMIX_post_create_environment();
 
-XBT_PRIVATE simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(const char *name);
+XBT_PRIVATE simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(std::string name);
 
 #endif
 
 #endif
index 9a98d8d..3d752fd 100644 (file)
@@ -85,7 +85,7 @@ XBT_PUBLIC_DATA MSG_Global_t msg_global;
 
 /*************************************************************/
 XBT_PRIVATE void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_proc);
 
 /*************************************************************/
 XBT_PRIVATE void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_proc);
-XBT_PRIVATE smx_actor_t MSG_process_create_from_SIMIX(const char* name, simgrid::simix::ActorCode code, void* data,
+XBT_PRIVATE smx_actor_t MSG_process_create_from_SIMIX(std::string name, simgrid::simix::ActorCode code, void* data,
                                                       sg_host_t host,
                                                       std::unordered_map<std::string, std::string>* properties,
                                                       smx_actor_t parent_process);
                                                       sg_host_t host,
                                                       std::unordered_map<std::string, std::string>* properties,
                                                       smx_actor_t parent_process);
index 2c6ef63..b3962ba 100644 (file)
@@ -57,7 +57,7 @@ void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_actor)
 }
 
 /* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
 }
 
 /* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
-smx_actor_t MSG_process_create_from_SIMIX(const char* name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
+smx_actor_t MSG_process_create_from_SIMIX(std::string name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
                                           std::unordered_map<std::string, std::string>* properties,
                                           smx_actor_t /*parent_process*/)
 {
                                           std::unordered_map<std::string, std::string>* properties,
                                           smx_actor_t /*parent_process*/)
 {
@@ -74,7 +74,7 @@ smx_actor_t MSG_process_create_from_SIMIX(const char* name, simgrid::simix::Acto
  */
 msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *data, msg_host_t host)
 {
  */
 msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *data, msg_host_t host)
 {
-  return MSG_process_create_with_environment(name, code, data, host, 0, nullptr, nullptr);
+  return MSG_process_create_with_environment(name == nullptr ? "" : name, code, data, host, 0, nullptr, nullptr);
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -146,8 +146,8 @@ msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_fun
   return res;
 }
 
   return res;
 }
 
-msg_process_t MSG_process_create_from_stdfunc(const char* name, simgrid::simix::ActorCode code, void* data, msg_host_t host,
-                                              std::unordered_map<std::string, std::string>* properties)
+msg_process_t MSG_process_create_from_stdfunc(std::string name, simgrid::simix::ActorCode code, void* data,
+                                              msg_host_t host, std::unordered_map<std::string, std::string>* properties)
 {
   xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr");
   simgrid::msg::ActorExt* msgExt = new simgrid::msg::ActorExt(data);
 {
   xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr");
   simgrid::msg::ActorExt* msgExt = new simgrid::msg::ActorExt(data);
index 42fae54..0e3ee32 100644 (file)
@@ -36,13 +36,13 @@ ActorPtr Actor::self()
   return self_context->process()->iface();
 }
 
   return self_context->process()->iface();
 }
 
-ActorPtr Actor::create(const char* name, s4u::Host* host, std::function<void()> code)
+ActorPtr Actor::create(std::string name, s4u::Host* host, std::function<void()> code)
 {
   simgrid::kernel::actor::ActorImpl* actor = simcall_process_create(name, std::move(code), nullptr, host, nullptr);
   return actor->iface();
 }
 
 {
   simgrid::kernel::actor::ActorImpl* actor = simcall_process_create(name, std::move(code), nullptr, host, nullptr);
   return actor->iface();
 }
 
-ActorPtr Actor::create(const char* name, s4u::Host* host, const char* function, std::vector<std::string> args)
+ActorPtr Actor::create(std::string name, s4u::Host* host, std::string function, std::vector<std::string> args)
 {
   simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
   simgrid::simix::ActorCode code            = factory(std::move(args));
 {
   simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
   simgrid::simix::ActorCode code            = factory(std::move(args));
@@ -225,12 +225,12 @@ std::unordered_map<std::string, std::string>* Actor::get_properties()
 }
 
 /** Retrieve the property value (or nullptr if not set) */
 }
 
 /** Retrieve the property value (or nullptr if not set) */
-const char* Actor::get_property(const char* key)
+const char* Actor::get_property(std::string key)
 {
   return simgrid::simix::simcall([this, key] { return pimpl_->get_property(key); });
 }
 
 {
   return simgrid::simix::simcall([this, key] { return pimpl_->get_property(key); });
 }
 
-void Actor::set_property(const char* key, const char* value)
+void Actor::set_property(std::string key, std::string value)
 {
   simgrid::simix::simcall([this, key, value] { pimpl_->set_property(key, value); });
 }
 {
   simgrid::simix::simcall([this, key, value] { pimpl_->set_property(key, value); });
 }
index aed56e7..e28bbc2 100644 (file)
@@ -280,14 +280,14 @@ void SIMIX_maestro_create(void (*code)(void*), void* data)
  *
  * \return the process created
  */
  *
  * \return the process created
  */
-smx_actor_t SIMIX_process_create(const char* name, simgrid::simix::ActorCode code, void* data, simgrid::s4u::Host* host,
+smx_actor_t SIMIX_process_create(std::string name, simgrid::simix::ActorCode code, void* data, simgrid::s4u::Host* host,
                                  std::unordered_map<std::string, std::string>* properties, smx_actor_t parent_process)
 {
 
                                  std::unordered_map<std::string, std::string>* properties, smx_actor_t parent_process)
 {
 
-  XBT_DEBUG("Start process %s on host '%s'", name, host->get_cname());
+  XBT_DEBUG("Start process %s on host '%s'", name.c_str(), host->get_cname());
 
   if (host->is_off()) {
 
   if (host->is_off()) {
-    XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, host->get_cname());
+    XBT_WARN("Cannot launch process '%s' on failed host '%s'", name.c_str(), host->get_cname());
     return nullptr;
   }
 
     return nullptr;
   }
 
@@ -776,11 +776,9 @@ void SIMIX_process_on_exit(smx_actor_t process, std::function<void(int, void*)>
  * \param argv second argument passed to \a code
  * \param properties the properties of the process
  */
  * \param argv second argument passed to \a code
  * \param properties the properties of the process
  */
-smx_actor_t simcall_process_create(const char* name, xbt_main_func_t code, void* data, sg_host_t host, int argc,
+smx_actor_t simcall_process_create(std::string name, xbt_main_func_t code, void* data, sg_host_t host, int argc,
                                    char** argv, std::unordered_map<std::string, std::string>* properties)
 {
                                    char** argv, std::unordered_map<std::string, std::string>* properties)
 {
-  if (name == nullptr)
-    name = "";
   auto wrapped_code = simgrid::xbt::wrap_main(code, argc, argv);
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   auto wrapped_code = simgrid::xbt::wrap_main(code, argc, argv);
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
@@ -789,11 +787,9 @@ smx_actor_t simcall_process_create(const char* name, xbt_main_func_t code, void*
   return res;
 }
 
   return res;
 }
 
-smx_actor_t simcall_process_create(const char* name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
+smx_actor_t simcall_process_create(std::string name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
                                    std::unordered_map<std::string, std::string>* properties)
 {
                                    std::unordered_map<std::string, std::string>* properties)
 {
-  if (name == nullptr)
-    name = "";
   smx_actor_t self = SIMIX_process_self();
   return simgrid::simix::simcall([name, code, data, host, properties, self] {
     return SIMIX_process_create(name, std::move(code), data, host, properties, self);
   smx_actor_t self = SIMIX_process_self();
   return simgrid::simix::simcall([name, code, data, host, properties, self] {
     return SIMIX_process_create(name, std::move(code), data, host, properties, self);
index 1a3c47b..5c1bfca 100644 (file)
@@ -150,7 +150,7 @@ XBT_PUBLIC void create_maestro(std::function<void()> code);
 
 typedef simgrid::kernel::actor::ActorImpl* smx_actor_t;
 
 
 typedef simgrid::kernel::actor::ActorImpl* smx_actor_t;
 
-XBT_PRIVATE smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, void* data, sg_host_t host,
+XBT_PRIVATE smx_actor_t SIMIX_process_create(std::string name, std::function<void()> code, void* data, sg_host_t host,
                                              std::unordered_map<std::string, std::string>* properties,
                                              smx_actor_t parent_process);
 
                                              std::unordered_map<std::string, std::string>* properties,
                                              smx_actor_t parent_process);
 
index 79a4993..1033c13 100644 (file)
@@ -96,7 +96,7 @@ void SIMIX_function_register_default(xbt_main_func_t code)
  * \param name the reference name of the function.
  * \return The #smx_actor_t or nullptr.
  */
  * \param name the reference name of the function.
  * \return The #smx_actor_t or nullptr.
  */
-simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(const char *name)
+simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(std::string name)
 {
   xbt_assert(simix_global,
               "SIMIX_global_init has to be called before SIMIX_get_actor_code_factory.");
 {
   xbt_assert(simix_global,
               "SIMIX_global_init has to be called before SIMIX_get_actor_code_factory.");