From 62983a196bc73bd07ce7b780297fa51528822860 Mon Sep 17 00:00:00 2001 From: SUTER Frederic Date: Mon, 12 Apr 2021 18:23:55 +0200 Subject: [PATCH] please clang (?) and make properties optional to create an ActorImpl --- src/bindings/java/jmsg_process.cpp | 4 +--- src/kernel/actor/ActorImpl.cpp | 13 +++---------- src/kernel/actor/ActorImpl.hpp | 6 ++---- src/s4u/s4u_Actor.cpp | 3 ++- src/surf/HostImpl.cpp | 3 ++- src/surf/sg_platf.cpp | 9 +++++---- 6 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/bindings/java/jmsg_process.cpp b/src/bindings/java/jmsg_process.cpp index 1ab550cafb..81443177fa 100644 --- a/src/bindings/java/jmsg_process.cpp +++ b/src/bindings/java/jmsg_process.cpp @@ -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(); diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index c09c773b73..6bd069817b 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -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& 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& 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; diff --git a/src/kernel/actor/ActorImpl.hpp b/src/kernel/actor/ActorImpl.hpp index 6289efdbd6..657d6ed3a7 100644 --- a/src/kernel/actor/ActorImpl.hpp +++ b/src/kernel/actor/ActorImpl.hpp @@ -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& properties, const ActorImpl* parent_actor); - static ActorImplPtr attach(const std::string& name, void* data, s4u::Host* host, - const std::unordered_map& 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>> on_exit; - ProcessArg() = default; + ProcessArg() = delete; explicit ProcessArg(const std::string& name, const std::function& code, void* data, s4u::Host* host, double kill_time, const std::unordered_map& properties, diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 7cb8a48d5e..80eebd7465 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -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"); } diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 02796851e1..b2cc1cfeb7 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -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) diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 613f2a9b7b..a0853f368e 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -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); -- 2.20.1