From: Frederic Suter Date: Thu, 11 Jan 2018 14:48:46 +0000 (+0100) Subject: refactoring and cosmetics X-Git-Tag: v3.19~364 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/af459dff2b5461c2dbc61e5b5cbdc302f92d2404 refactoring and cosmetics --- diff --git a/src/simix/ActorImpl.hpp b/src/simix/ActorImpl.hpp index ba966d1c38..0b4c9e6d46 100644 --- a/src/simix/ActorImpl.hpp +++ b/src/simix/ActorImpl.hpp @@ -25,11 +25,23 @@ class ProcessArg { public: std::string name; std::function code; - void *data = nullptr; - sg_host_t host = nullptr; + void* data = nullptr; + s4u::Host* host = nullptr; double kill_time = 0.0; std::shared_ptr> properties; bool auto_restart = false; + ProcessArg() = default; + explicit ProcessArg(std::string name, std::function code, void* data, s4u::Host* host, double kill_time, + std::shared_ptr> properties, bool auto_restart) + : name(name) + , code(std::move(code)) + , data(data) + , host(host) + , kill_time(kill_time) + , properties(properties) + , auto_restart(auto_restart) + { + } }; class ActorImpl : public simgrid::surf::PropertyHolder { diff --git a/src/simix/smx_deployment.cpp b/src/simix/smx_deployment.cpp index f59d64f6bd..c9ce06ae5b 100644 --- a/src/simix/smx_deployment.cpp +++ b/src/simix/smx_deployment.cpp @@ -140,7 +140,7 @@ void SIMIX_process_set_function(const char* process_host, const char* process_fu actor.kill_time = process_kill_time; actor.start_time = process_start_time; actor.on_failure = ActorOnFailure::DIE; - sg_platf_new_process(&actor); + sg_platf_new_actor(&actor); } namespace simgrid { diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index ed49843c8a..da84fe54ba 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -112,14 +112,9 @@ void SIMIX_host_add_auto_restart_process(sg_host_t host, const char* name, std:: double kill_time, std::map* properties, int auto_restart) { - smx_process_arg_t arg = new simgrid::simix::ProcessArg(); - arg->name = name; - arg->code = std::move(code); - arg->data = data; - arg->host = host; - arg->kill_time = kill_time; + simgrid::simix::ProcessArg* arg = + new simgrid::simix::ProcessArg(name, code, data, host, kill_time, nullptr, auto_restart); arg->properties.reset(properties, [](decltype(properties)) {}); - arg->auto_restart = auto_restart; if (host->isOff() && watched_hosts.find(host->getCname()) == watched_hosts.end()) { watched_hosts.insert(host->getCname()); @@ -127,6 +122,7 @@ void SIMIX_host_add_auto_restart_process(sg_host_t host, const char* name, std:: } host->extension()->auto_restart_processes.push_back(arg); } + /** @brief Restart the list of processes that have been registered to the host */ void SIMIX_host_autorestart(sg_host_t host) { @@ -148,7 +144,6 @@ void SIMIX_host_autorestart(sg_host_t host) boost::intrusive_ptr SIMIX_execution_start(const char* name, double flops_amount, double priority, double bound, sg_host_t host) { - /* alloc structures and initialize */ simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr(new simgrid::kernel::activity::ExecImpl(name, host)); diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 9e51f91ad7..c01a8d8a38 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -409,12 +409,12 @@ void sg_platf_new_bypassRoute(sg_platf_route_cbarg_t bypassRoute) bypassRoute->link_list, bypassRoute->symmetrical); } -void sg_platf_new_process(ActorCreationArgs* actor) +void sg_platf_new_actor(ActorCreationArgs* actor) { sg_host_t host = sg_host_by_name(actor->host); if (not host) { // The requested host does not exist. Do a nice message to the user - std::string msg = std::string("Cannot create process '") + actor->function + "': host '" + actor->host + + std::string msg = std::string("Cannot create actor '") + actor->function + "': host '" + actor->host + "' does not exist\nExisting hosts: '"; std::vector list; @@ -436,33 +436,20 @@ void sg_platf_new_process(ActorCreationArgs* actor) double start_time = actor->start_time; double kill_time = actor->kill_time; - int auto_restart = actor->on_failure == ActorOnFailure::DIE ? 0 : 1; + bool auto_restart = actor->on_failure != ActorOnFailure::DIE; - std::string process_name = actor->args[0]; + std::string actor_name = actor->args[0]; std::function code = factory(std::move(actor->args)); std::shared_ptr> properties(actor->properties); - smx_process_arg_t arg = nullptr; - - arg = new simgrid::simix::ProcessArg(); - arg->name = process_name; - arg->code = code; - arg->data = nullptr; - arg->host = host; - arg->kill_time = kill_time; - arg->properties = properties; + simgrid::simix::ProcessArg* arg = + new simgrid::simix::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart); host->extension()->boot_processes.push_back(arg); if (start_time > SIMIX_get_clock()) { - arg = new simgrid::simix::ProcessArg(); - arg->name = process_name; - arg->code = std::move(code); - arg->data = nullptr; - arg->host = host; - arg->kill_time = kill_time; - arg->properties = properties; + arg = new simgrid::simix::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart); XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->getCname(), start_time); SIMIX_timer_set(start_time, [arg, auto_restart]() { diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index 8848ab2eec..dd7d26dbf7 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -222,7 +222,7 @@ XBT_PUBLIC(void) sg_platf_new_storage(StorageCreationArgs* storage); // Add a st XBT_PUBLIC(void) sg_platf_new_storage_type(StorageTypeCreationArgs* storage_type); XBT_PUBLIC(void) sg_platf_new_mount(MountCreationArgs* mount); -XBT_PUBLIC(void) sg_platf_new_process(ActorCreationArgs* actor); +XBT_PUBLIC(void) sg_platf_new_actor(ActorCreationArgs* actor); XBT_PRIVATE void sg_platf_trace_connect(TraceConnectCreationArgs* trace_connect); /* Prototypes of the functions offered by flex */ diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index b94cbbf045..272755c325 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -928,7 +928,7 @@ void ETag_surfxml_actor() break; } - sg_platf_new_process(&actor); + sg_platf_new_actor(&actor); } void STag_surfxml_argument(){