Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill a redudant example
[simgrid.git] / src / surf / network_cm02.cpp
index d88a052..432189d 100644 (file)
@@ -40,7 +40,6 @@ void surf_network_model_init_LegrandVelho(void)
   if (surf_network_model)
     return;
 
-  simgrid::surf::on_link.connect(netlink_parse_init);
   surf_network_model = new simgrid::surf::NetworkCm02Model();
   xbt_dynar_push(all_existing_models, &surf_network_model);
 
@@ -66,7 +65,6 @@ void surf_network_model_init_CM02(void)
   if (surf_network_model)
     return;
 
-  simgrid::surf::on_link.connect(netlink_parse_init);
   surf_network_model = new simgrid::surf::NetworkCm02Model();
   xbt_dynar_push(all_existing_models, &surf_network_model);
 
@@ -90,7 +88,6 @@ void surf_network_model_init_Reno(void)
   if (surf_network_model)
     return;
 
-  simgrid::surf::on_link.connect(netlink_parse_init);
   surf_network_model = new simgrid::surf::NetworkCm02Model();
   xbt_dynar_push(all_existing_models, &surf_network_model);
 
@@ -108,7 +105,6 @@ void surf_network_model_init_Reno2(void)
   if (surf_network_model)
     return;
 
-  simgrid::surf::on_link.connect(netlink_parse_init);
   surf_network_model = new simgrid::surf::NetworkCm02Model();
   xbt_dynar_push(all_existing_models, &surf_network_model);
 
@@ -125,7 +121,6 @@ void surf_network_model_init_Vegas(void)
   if (surf_network_model)
     return;
 
-  simgrid::surf::on_link.connect(netlink_parse_init);
   surf_network_model = new simgrid::surf::NetworkCm02Model();
   xbt_dynar_push(all_existing_models, &surf_network_model);
 
@@ -215,7 +210,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
       XBT_DEBUG("Action %p finished", action);
       action->setRemains(0);
       action->finish();
-      action->setState(SURF_ACTION_DONE);
+      action->setState(Action::State::done);
       action->heapRemove(actionHeap_);
 
       action->gapRemove();
@@ -280,12 +275,12 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta)
     if ((action->getRemains() <= 0) &&
         (lmm_get_variable_weight(action->getVariable()) > 0)) {
       action->finish();
-      action->setState(SURF_ACTION_DONE);
+      action->setState(Action::State::done);
       action->gapRemove();
     } else if (((action->getMaxDuration() != NO_MAX_DURATION)
         && (action->getMaxDuration() <= 0))) {
       action->finish();
-      action->setState(SURF_ACTION_DONE);
+      action->setState(Action::State::done);
       action->gapRemove();
     }
   }
@@ -325,8 +320,8 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, double size, d
 
   action->rate_ = rate;
   if (updateMechanism_ == UM_LAZY) {
-    action->m_indexHeap = -1;
-    action->m_lastUpdate = surf_get_clock();
+    action->indexHeap_ = -1;
+    action->lastUpdate_ = surf_get_clock();
   }
 
   bandwidth_bound = -1.0;
@@ -355,14 +350,14 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, double size, d
     constraints_per_variable += back_route->size();
 
   if (action->latency_ > 0) {
-    action->p_variable = lmm_variable_new(maxminSystem_, action, 0.0, -1.0, constraints_per_variable);
+    action->variable_ = lmm_variable_new(maxminSystem_, action, 0.0, -1.0, constraints_per_variable);
     if (updateMechanism_ == UM_LAZY) {
       // add to the heap the event when the latency is payed
-      XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->m_lastUpdate);
-      action->heapInsert(actionHeap_, action->latency_ + action->m_lastUpdate, route->empty() ? NORMAL : LATENCY);
+      XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->lastUpdate_);
+      action->heapInsert(actionHeap_, action->latency_ + action->lastUpdate_, route->empty() ? NORMAL : LATENCY);
     }
   } else
-    action->p_variable = lmm_variable_new(maxminSystem_, action, 1.0, -1.0, constraints_per_variable);
+    action->variable_ = lmm_variable_new(maxminSystem_, action, 1.0, -1.0, constraints_per_variable);
 
   if (action->rate_ < 0) {
     lmm_update_variable_bound(maxminSystem_, action->getVariable(), (action->latCurrent_ > 0) ? sg_tcp_gamma / (2.0 * action->latCurrent_) : -1.0);
@@ -386,7 +381,7 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, double size, d
   delete route;
   XBT_OUT();
 
-  networkCommunicateCallbacks(action, src, dst, size, rate);
+  Link::onCommunicate(action, src, dst);
   return action;
 }
 
@@ -438,10 +433,10 @@ void NetworkCm02Link::apply_event(tmgr_trace_iterator_t triggered, double value)
       while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) {
         Action *action = static_cast<Action*>( lmm_variable_id(var) );
 
-        if (action->getState() == SURF_ACTION_RUNNING ||
-            action->getState() == SURF_ACTION_READY) {
+        if (action->getState() == Action::State::running ||
+            action->getState() == Action::State::ready) {
           action->setFinishTime(now);
-          action->setState(SURF_ACTION_FAILED);
+          action->setState(Action::State::failed);
         }
       }
     }
@@ -514,36 +509,36 @@ void NetworkCm02Action::updateRemainingLazy(double now)
 {
   double delta = 0.0;
 
-  if (m_suspended != 0)
+  if (suspended_ != 0)
     return;
 
-  delta = now - m_lastUpdate;
+  delta = now - lastUpdate_;
 
-  if (m_remains > 0) {
-    XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate);
-    double_update(&(m_remains), m_lastValue * delta, sg_maxmin_precision*sg_surf_precision);
+  if (remains_ > 0) {
+    XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, remains_, lastUpdate_);
+    double_update(&(remains_), lastValue_ * delta, sg_maxmin_precision*sg_surf_precision);
 
-    XBT_DEBUG("Updating action(%p): remains is now %f", this, m_remains);
+    XBT_DEBUG("Updating action(%p): remains is now %f", this, remains_);
   }
 
-  if (m_maxDuration != NO_MAX_DURATION)
-    double_update(&m_maxDuration, delta, sg_surf_precision);
+  if (maxDuration_ != NO_MAX_DURATION)
+    double_update(&maxDuration_, delta, sg_surf_precision);
 
-  if (m_remains <= 0 &&
+  if (remains_ <= 0 &&
       (lmm_get_variable_weight(getVariable()) > 0)) {
     finish();
-    setState(SURF_ACTION_DONE);
+    setState(Action::State::done);
 
     heapRemove(getModel()->getActionHeap());
-  } else if (((m_maxDuration != NO_MAX_DURATION)
-      && (m_maxDuration <= 0))) {
+  } else if (((maxDuration_ != NO_MAX_DURATION)
+      && (maxDuration_ <= 0))) {
     finish();
-    setState(SURF_ACTION_DONE);
+    setState(Action::State::done);
     heapRemove(getModel()->getActionHeap());
   }
 
-  m_lastUpdate = now;
-  m_lastValue = lmm_variable_getvalue(getVariable());
+  lastUpdate_ = now;
+  lastValue_ = lmm_variable_getvalue(getVariable());
 }
 
 }