X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/eadce057a2c8e09df65641e77935bd9ffc905440..ec2492b4748c7f013c4852f7743ab8707a70ca18:/src/kernel/actor/ActorImpl.cpp diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 9a646da55c..aec21aae32 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -93,8 +93,7 @@ ActorImplPtr ActorImpl::attach(const std::string& name, void* data, s4u::Host* h /* Add properties */ if (properties != nullptr) - for (auto const& kv : *properties) - actor->set_property(kv.first, kv.second); + actor->set_properties(*properties); /* Add the process to it's host process list */ host->pimpl_->process_list_.push_back(*actor); @@ -142,11 +141,10 @@ void ActorImpl::cleanup() // Execute the termination callbacks bool failed = context_->iwannadie; - while (not on_exit.empty()) { - auto exit_fun = on_exit.back(); - on_exit.pop_back(); - exit_fun(failed); - } + for (auto exit_fun = on_exit->crbegin(); exit_fun != on_exit->crend(); ++exit_fun) + (*exit_fun)(failed); + if (not has_to_auto_restart()) + on_exit->clear(); /* cancel non-blocking activities */ for (auto activity : comms) @@ -334,6 +332,7 @@ s4u::Actor* ActorImpl::restart() // start the new actor ActorImplPtr actor = ActorImpl::create(arg.name, std::move(arg.code), arg.data, arg.host, arg.properties.get(), nullptr); + *actor->on_exit = std::move(*arg.on_exit); actor->set_kill_time(arg.kill_time); actor->set_auto_restart(arg.auto_restart); @@ -487,8 +486,7 @@ ActorImplPtr ActorImpl::create(const std::string& name, const simix::ActorCode& /* Add properties */ if (properties != nullptr) - for (auto const& kv : *properties) - actor->set_property(kv.first, kv.second); + actor->set_properties(*properties); actor->start(code); @@ -652,7 +650,7 @@ void SIMIX_process_on_exit(smx_actor_t actor, const std::function& fun) { xbt_assert(actor, "current process not found: are you in maestro context ?"); - actor->on_exit.emplace_back(fun); + actor->on_exit->emplace_back(fun); } /** @brief Restart a process, starting it again from the beginning. */