Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please clang (?) and make properties optional to create an ActorImpl
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 12 Apr 2021 16:23:55 +0000 (18:23 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 12 Apr 2021 16:23:55 +0000 (18:23 +0200)
src/bindings/java/jmsg_process.cpp
src/kernel/actor/ActorImpl.cpp
src/kernel/actor/ActorImpl.hpp
src/s4u/s4u_Actor.cpp
src/surf/HostImpl.cpp
src/surf/sg_platf.cpp

index 1ab550c..8144317 100644 (file)
@@ -76,9 +76,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv* env, jobject
   smx_actor_t self  = SIMIX_process_self();
   sg_host_t host    = jhost_get_native(env, jhost);
   smx_actor_t actor = simgrid::kernel::actor::simcall([name, actor_code, host, self] {
-    return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(actor_code), nullptr, host, nullptr,
-                                                     self)
-        .get();
+    return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(actor_code), nullptr, host, self).get();
   });
   sg_actor_yield();
 
index c09c773..6bd0698 100644 (file)
@@ -89,8 +89,7 @@ ActorImpl::~ActorImpl()
  * In the future, it might be extended in order to attach other threads created by a third party library.
  */
 
-ActorImplPtr ActorImpl::attach(const std::string& name, void* data, s4u::Host* host,
-                               const std::unordered_map<std::string, std::string>& properties)
+ActorImplPtr ActorImpl::attach(const std::string& name, void* data, s4u::Host* host)
 {
   // This is mostly a copy/paste from create(), it'd be nice to share some code between those two functions.
 
@@ -110,9 +109,6 @@ ActorImplPtr ActorImpl::attach(const std::string& name, void* data, s4u::Host* h
   xbt_assert(simix_global != nullptr, "simix is not initialized, please call MSG_init first");
   actor->context_.reset(simix_global->context_factory->attach(actor));
 
-  /* Add properties */
-  actor->set_properties(properties);
-
   /* Add the actor to it's host actor list */
   host->get_impl()->add_actor(actor);
 
@@ -365,7 +361,8 @@ s4u::Actor* ActorImpl::restart()
   context::Context::self()->get_actor()->kill(this);
 
   // start the new actor
-  ActorImplPtr actor = ActorImpl::create(arg.name, arg.code, arg.data, arg.host, arg.properties, nullptr);
+  ActorImplPtr actor = ActorImpl::create(arg.name, arg.code, arg.data, arg.host, nullptr);
+  actor->set_properties(arg.properties);
   *actor->on_exit = std::move(*arg.on_exit);
   actor->set_kill_time(arg.kill_time);
   actor->set_auto_restart(arg.auto_restart);
@@ -508,7 +505,6 @@ ActorImpl* ActorImpl::start(const ActorCode& code)
 }
 
 ActorImplPtr ActorImpl::create(const std::string& name, const ActorCode& code, void* data, s4u::Host* host,
-                               const std::unordered_map<std::string, std::string>& properties,
                                const ActorImpl* parent_actor)
 {
   XBT_DEBUG("Start actor %s@'%s'", name.c_str(), host->get_cname());
@@ -522,9 +518,6 @@ ActorImplPtr ActorImpl::create(const std::string& name, const ActorCode& code, v
   /* actor data */
   actor->set_user_data(data);
 
-  /* Add properties */
-  actor->set_properties(properties);
-
   actor->start(code);
 
   return actor;
index 6289efd..657d6ed 100644 (file)
@@ -121,10 +121,8 @@ public:
   ActorImpl* start(const ActorCode& code);
 
   static ActorImplPtr create(const std::string& name, const ActorCode& code, void* data, s4u::Host* host,
-                             const std::unordered_map<std::string, std::string>& properties,
                              const ActorImpl* parent_actor);
-  static ActorImplPtr attach(const std::string& name, void* data, s4u::Host* host,
-                             const std::unordered_map<std::string, std::string>& properties);
+  static ActorImplPtr attach(const std::string& name, void* data, s4u::Host* host);
   static void detach();
   void cleanup();
   void exit();
@@ -162,7 +160,7 @@ public:
   /* list of functions executed when the process dies */
   const std::shared_ptr<std::vector<std::function<void(bool)>>> on_exit;
 
-  ProcessArg()                                                             = default;
+  ProcessArg() = delete;
 
   explicit ProcessArg(const std::string& name, const std::function<void()>& code, void* data, s4u::Host* host,
                       double kill_time, const std::unordered_map<std::string, std::string>& properties,
index 7cb8a48..80eebd7 100644 (file)
@@ -745,7 +745,8 @@ sg_actor_t sg_actor_attach(const char* name, void* data, sg_host_t host, xbt_dic
   /* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
   smx_actor_t actor = nullptr;
   try {
-    actor = simgrid::kernel::actor::ActorImpl::attach(name, data, host, props).get();
+    actor = simgrid::kernel::actor::ActorImpl::attach(name, data, host).get();
+    actor->set_properties(props);
   } catch (simgrid::HostFailureException const&) {
     xbt_die("Could not attach");
   }
index 0279685..b2cc1cf 100644 (file)
@@ -77,7 +77,8 @@ void HostImpl::turn_on() const
   for (auto const& arg : actors_at_boot_) {
     XBT_DEBUG("Booting Actor %s(%s) right now", arg->name.c_str(), arg->host->get_cname());
     simgrid::kernel::actor::ActorImplPtr actor =
-        simgrid::kernel::actor::ActorImpl::create(arg->name, arg->code, nullptr, arg->host, arg->properties, nullptr);
+        simgrid::kernel::actor::ActorImpl::create(arg->name, arg->code, nullptr, arg->host, nullptr);
+    actor->set_properties(arg->properties);
     if (arg->on_exit)
       *actor->on_exit = *arg->on_exit;
     if (arg->kill_time >= 0)
index 613f2a9..a0853f3 100644 (file)
@@ -336,8 +336,9 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
 
     XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->get_cname(), start_time);
     simgrid::simix::Timer::set(start_time, [arg, auto_restart]() {
-      simgrid::kernel::actor::ActorImplPtr new_actor = simgrid::kernel::actor::ActorImpl::create(
-          arg->name.c_str(), arg->code, arg->data, arg->host, arg->properties, nullptr);
+      simgrid::kernel::actor::ActorImplPtr new_actor =
+          simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), arg->code, arg->data, arg->host, nullptr);
+      new_actor->set_properties(arg->properties);
       if (arg->kill_time >= 0)
         new_actor->set_kill_time(arg->kill_time);
       if (auto_restart)
@@ -349,8 +350,8 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
 
     try {
       simgrid::kernel::actor::ActorImplPtr new_actor = nullptr;
-      new_actor =
-          simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), code, nullptr, host, arg->properties, nullptr);
+      new_actor = simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), code, nullptr, host, nullptr);
+      new_actor->set_properties(arg->properties);
       /* The actor creation will fail if the host is currently dead, but that's fine */
       if (arg->kill_time >= 0)
         new_actor->set_kill_time(arg->kill_time);