Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
factor attachment of state traces to resources
[simgrid.git] / src / kernel / resource / Resource.cpp
index 72899f0..bcab6db 100644 (file)
@@ -6,6 +6,7 @@
 #include "simgrid/kernel/resource/Resource.hpp"
 #include "src/kernel/lmm/maxmin.hpp" // Constraint
 #include "src/surf/surf_interface.hpp"
+#include "src/surf/trace_mgr.hpp"
 
 namespace simgrid {
 namespace kernel {
@@ -62,6 +63,13 @@ bool Resource::operator==(const Resource& other) const
   return name_ == other.name_;
 }
 
+void Resource::set_state_trace(tmgr_trace_t trace)
+{
+  xbt_assert(state_event_ == nullptr, "Cannot set a second state trace to %s", get_cname());
+
+  state_event_ = future_evt_set->add_trace(trace, this);
+}
+
 kernel::lmm::Constraint* Resource::get_constraint() const
 {
   return constraint_;