Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't use pass-by-value for large parameters.
[simgrid.git] / src / msg / msg_task.cpp
index 803c9db..8068a8d 100644 (file)
@@ -27,8 +27,8 @@ Task::Task(std::string name, double flops_amount, double bytes_amount, void* dat
     MC_ignore_heap(&(id_), sizeof(id_));
 }
 
-Task::Task(std::string name, std::vector<s4u::Host*> hosts, std::vector<double> flops_amount,
-           std::vector<double> bytes_amount, void* data)
+Task::Task(std::string name, std::vector<s4u::Host*>&& hosts, std::vector<double>&& flops_amount,
+           std::vector<double>&& bytes_amount, void* data)
     : Task(std::move(name), 1.0, 0, data)
 {
   parallel_             = true;
@@ -115,8 +115,8 @@ s4u::CommPtr Task::send_async(std::string alias, void_f_pvoid_t cleanup, bool de
   this->comm = nullptr;
   msg_global->sent_msg++;
 
-  s4u::CommPtr comm = s4u::Mailbox::by_name(alias)->put_init(this, bytes_amount)->set_rate(get_rate());
-  this->comm        = comm;
+  s4u::CommPtr s4u_comm = s4u::Mailbox::by_name(alias)->put_init(this, bytes_amount)->set_rate(get_rate());
+  comm                  = s4u_comm;
 
   if (detached)
     comm->detach(cleanup);
@@ -124,7 +124,7 @@ s4u::CommPtr Task::send_async(std::string alias, void_f_pvoid_t cleanup, bool de
     comm->start();
 
   if (TRACE_is_enabled() && has_tracing_category())
-    simgrid::simix::simcall([comm, this] { comm->get_impl()->set_category(std::move(tracing_category_)); });
+    simgrid::simix::simcall([this] { comm->get_impl()->set_category(std::move(tracing_category_)); });
 
   return comm;
 }
@@ -134,6 +134,7 @@ msg_error_t Task::send(std::string alias, double timeout)
   msg_error_t ret = MSG_OK;
   /* Try to send it */
   try {
+    comm = nullptr; // needed, otherwise MC gets confused.
     s4u::CommPtr s4u_comm = send_async(alias, nullptr, false);
     comm                  = s4u_comm;
     comm->wait_for(timeout);