Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move hosts_ to private, and deal with consequences
[simgrid.git] / src / kernel / activity / CommImpl.cpp
index 0dc962a..e027255 100644 (file)
@@ -11,6 +11,7 @@
 #define SIMIX_H_NO_DEPRECATED_WARNING // avoid deprecation warning on include (remove with XBT_ATTRIB_DEPRECATED_v333)
 #include <simgrid/simix.h>
 
+#include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/activity/CommImpl.hpp"
 #include "src/kernel/activity/MailboxImpl.hpp"
 #include "src/kernel/actor/SimcallObserver.hpp"
@@ -61,13 +62,17 @@ CommImpl& CommImpl::set_type(CommImplType type)
 
 CommImpl& CommImpl::set_source(s4u::Host* from)
 {
+  xbt_assert( from_ == nullptr );
   from_ = from;
+  add_host(from);
   return *this;
 }
 
 CommImpl& CommImpl::set_destination(s4u::Host* to)
 {
+  xbt_assert( to_ == nullptr );
   to_ = to;
+  add_host(to_);
   return *this;
 }
 
@@ -107,6 +112,7 @@ CommImpl& CommImpl::set_dst_buff(unsigned char* buff, size_t* size)
 CommImpl& CommImpl::detach()
 {
   detached_ = true;
+  EngineImpl::get_instance()->get_maestro()->activities_.emplace_back(this);
   return *this;
 }