Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
refactoring and cosmetics
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 11 Jan 2018 14:48:46 +0000 (15:48 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 11 Jan 2018 14:48:46 +0000 (15:48 +0100)
src/simix/ActorImpl.hpp
src/simix/smx_deployment.cpp
src/simix/smx_host.cpp
src/surf/sg_platf.cpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp

index ba966d1..0b4c9e6 100644 (file)
@@ -25,11 +25,23 @@ class ProcessArg {
 public:
   std::string name;
   std::function<void()> code;
 public:
   std::string name;
   std::function<void()> code;
-  void *data            = nullptr;
-  sg_host_t host        = nullptr;
+  voiddata            = nullptr;
+  s4u::Host* host       = nullptr;
   double kill_time      = 0.0;
   std::shared_ptr<std::map<std::string, std::string>> properties;
   bool auto_restart     = false;
   double kill_time      = 0.0;
   std::shared_ptr<std::map<std::string, std::string>> properties;
   bool auto_restart     = false;
+  ProcessArg()          = default;
+  explicit ProcessArg(std::string name, std::function<void()> code, void* data, s4u::Host* host, double kill_time,
+                      std::shared_ptr<std::map<std::string, std::string>> 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 {
 };
 
 class ActorImpl : public simgrid::surf::PropertyHolder {
index f59d64f..c9ce06a 100644 (file)
@@ -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;
   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 {
 }
 
 namespace simgrid {
index ed49843..da84fe5 100644 (file)
@@ -112,14 +112,9 @@ void SIMIX_host_add_auto_restart_process(sg_host_t host, const char* name, std::
                                          double kill_time, std::map<std::string, std::string>* properties,
                                          int auto_restart)
 {
                                          double kill_time, std::map<std::string, std::string>* 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->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());
 
   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<simgrid::simix::Host>()->auto_restart_processes.push_back(arg);
 }
   }
   host->extension<simgrid::simix::Host>()->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)
 {
 /** @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<simgrid::kernel::activity::ExecImpl>
 SIMIX_execution_start(const char* name, double flops_amount, double priority, double bound, sg_host_t host)
 {
 boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
 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));
   /* alloc structures and initialize */
   simgrid::kernel::activity::ExecImplPtr exec =
       simgrid::kernel::activity::ExecImplPtr(new simgrid::kernel::activity::ExecImpl(name, host));
index 9e51f91..c01a8d8 100644 (file)
@@ -409,12 +409,12 @@ void sg_platf_new_bypassRoute(sg_platf_route_cbarg_t bypassRoute)
                                         bypassRoute->link_list, bypassRoute->symmetrical);
 }
 
                                         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
 {
   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<simgrid::s4u::Host*> list;
                       "' does not exist\nExisting hosts: '";
 
     std::vector<simgrid::s4u::Host*> list;
@@ -436,33 +436,20 @@ void sg_platf_new_process(ActorCreationArgs* actor)
 
   double start_time = actor->start_time;
   double kill_time  = actor->kill_time;
 
   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<void()> code = factory(std::move(actor->args));
   std::shared_ptr<std::map<std::string, std::string>> properties(actor->properties);
 
   std::function<void()> code = factory(std::move(actor->args));
   std::shared_ptr<std::map<std::string, std::string>> 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<simgrid::simix::Host>()->boot_processes.push_back(arg);
 
   if (start_time > SIMIX_get_clock()) {
 
 
   host->extension<simgrid::simix::Host>()->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]() {
 
     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]() {
index 8848ab2..dd7d26d 100644 (file)
@@ -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_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 */
 XBT_PRIVATE void sg_platf_trace_connect(TraceConnectCreationArgs* trace_connect);
 
 /* Prototypes of the functions offered by flex */
index b94cbbf..272755c 100644 (file)
@@ -928,7 +928,7 @@ void ETag_surfxml_actor()
     break;
   }
 
     break;
   }
 
-  sg_platf_new_process(&actor);
+  sg_platf_new_actor(&actor);
 }
 
 void STag_surfxml_argument(){
 }
 
 void STag_surfxml_argument(){