Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
prefer readable syntax instead of inlining functions
[simgrid.git] / src / surf / network_constant.cpp
index 166d70e..9a582d7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -32,7 +32,7 @@ LinkImpl* NetworkConstantModel::createLink(const std::string& name, double bw, d
 double NetworkConstantModel::nextOccuringEvent(double /*now*/)
 {
   double min = -1.0;
-  for (Action const& action : *getRunningActionSet()) {
+  for (kernel::resource::Action const& action : *getRunningActionSet()) {
     const NetworkConstantAction& net_action = static_cast<const NetworkConstantAction&>(action);
     if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min))
       min = net_action.latency_;
@@ -52,18 +52,18 @@ void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
         action.latency_ = 0.0;
       }
     }
-    action.updateRemains(action.getCost() * delta / action.initialLatency_);
-    if (action.getMaxDuration() != NO_MAX_DURATION)
-      action.updateMaxDuration(delta);
+    action.update_remains(action.get_cost() * delta / action.initialLatency_);
+    if (action.get_max_duration() != NO_MAX_DURATION)
+      action.update_max_duration(delta);
 
-    if ((action.getRemainsNoUpdate() <= 0) ||
-        ((action.getMaxDuration() != NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
-      action.finish(Action::State::done);
+    if ((action.get_remains_no_update() <= 0) ||
+        ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
+      action.finish(kernel::resource::Action::State::done);
     }
   }
 }
 
-Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
+kernel::resource::Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
 {
   NetworkConstantAction* action = new NetworkConstantAction(this, size, sg_latency_factor);
 
@@ -78,12 +78,15 @@ NetworkConstantAction::NetworkConstantAction(NetworkConstantModel* model_, doubl
     : NetworkAction(model_, size, false), initialLatency_(latency)
 {
   latency_ = latency;
-  if (latency_ <= 0.0) {
-    stateSet_ = model_->getDoneActionSet();
-    stateSet_->push_back(*this);
-  }
+  if (latency_ <= 0.0)
+    set_state(Action::State::done);
 };
 
 NetworkConstantAction::~NetworkConstantAction() = default;
+
+void NetworkConstantAction::updateRemainingLazy(double /*now*/)
+{
+  THROW_IMPOSSIBLE;
+}
 }
 }