Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[cpu_ti] small code untangling
[simgrid.git] / src / surf / cpu_ti.cpp
index d422089..c50f2f8 100644 (file)
@@ -385,17 +385,6 @@ int CpuTiTrace::binarySearch(double *array, double a, int low, int high)
 }
 }
 
-/*************
- * CallBacks *
- *************/
-
-static void cpu_ti_define_callbacks()
-{
-  simgrid::surf::on_postparse.connect([]() {
-    surf_cpu_model_pm->addTraces();
-  });
-}
-
 /*********
  * Model *
  *********/
@@ -406,13 +395,14 @@ void surf_cpu_model_init_ti()
   xbt_assert(!surf_cpu_model_vm,"CPU model already initialized. This should not happen.");
 
   surf_cpu_model_pm = new simgrid::surf::CpuTiModel();
+  xbt_dynar_push(all_existing_models, &surf_cpu_model_pm);
+
   surf_cpu_model_vm = new simgrid::surf::CpuTiModel();
+  xbt_dynar_push(all_existing_models, &surf_cpu_model_vm);
 
-  cpu_ti_define_callbacks();
-  simgrid::surf::Model *model_pm = static_cast<simgrid::surf::Model*>(surf_cpu_model_pm);
-  simgrid::surf::Model *model_vm = static_cast<simgrid::surf::Model*>(surf_cpu_model_vm);
-  xbt_dynar_push(all_existing_models, &model_pm);
-  xbt_dynar_push(all_existing_models, &model_vm);
+  simgrid::surf::on_postparse.connect([]() {
+    surf_cpu_model_pm->addTraces();
+  });
 }
 
 namespace simgrid {
@@ -614,8 +604,7 @@ void CpuTi::updateState(tmgr_trace_iterator_t event_type,
 
     p_availTrace = trace;
 
-    if (tmgr_trace_event_free(event_type))
-      p_speedEvent = NULL;
+    tmgr_trace_event_unref(&p_speedEvent);
 
   } else if (event_type == p_stateEvent) {
     if (value > 0) {
@@ -643,14 +632,10 @@ void CpuTi::updateState(tmgr_trace_iterator_t event_type,
         }
       }
     }
-    if (tmgr_trace_event_free(event_type))
-      p_stateEvent = NULL;
+    tmgr_trace_event_unref(&p_stateEvent);
   } else {
-    XBT_CRITICAL("Unknown event ! \n");
-    xbt_abort();
+    xbt_die("Unknown event!\n");
   }
-
-  return;
 }
 
 void CpuTi::updateActionsFinishTime(double now)
@@ -791,7 +776,7 @@ void CpuTi::updateRemainingAmount(double now)
   m_lastUpdate = now;
 }
 
-CpuAction *CpuTi::execute(double size)
+CpuAction *CpuTi::execution_start(double size)
 {
   XBT_IN("(%s,%g)", getName(), size);
   CpuTiAction *action = new CpuTiAction(static_cast<CpuTiModel*>(getModel()), size, isOff(), this);