Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplification commit
[simgrid.git] / src / kernel / resource / Action.cpp
index 020d08f..2111104 100644 (file)
@@ -24,9 +24,9 @@ Action::Action(simgrid::kernel::resource::Model* model, double cost, bool failed
     : remains_(cost), start_time_(surf_get_clock()), cost_(cost), model_(model), variable_(var)
 {
   if (failed)
-    state_set_ = get_model()->get_failed_action_set();
+    state_set_ = model_->get_failed_action_set();
   else
-    state_set_ = get_model()->get_started_action_set();
+    state_set_ = model_->get_started_action_set();
 
   state_set_->push_back(*this);
 }
@@ -36,12 +36,12 @@ Action::~Action()
   if (state_set_hook_.is_linked())
     simgrid::xbt::intrusive_erase(*state_set_, *this);
   if (get_variable())
-    get_model()->get_maxmin_system()->variable_free(get_variable());
+    model_->get_maxmin_system()->variable_free(get_variable());
 
   /* remove from heap on need (ie, if selective update) */
-  get_model()->get_action_heap().remove(this);
+  model_->get_action_heap().remove(this);
   if (modified_set_hook_.is_linked())
-    simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
+    simgrid::xbt::intrusive_erase(*model_->get_modified_set(), *this);
 }
 
 void Action::finish(Action::State state)
@@ -102,10 +102,10 @@ void Action::set_bound(double bound)
 {
   XBT_IN("(%p,%g)", this, bound);
   if (variable_)
-    get_model()->get_maxmin_system()->update_variable_bound(variable_, bound);
+    model_->get_maxmin_system()->update_variable_bound(variable_, bound);
 
-  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY && get_last_update() != surf_get_clock())
-    get_model()->get_action_heap().remove(this);
+  if (model_->is_update_lazy() && get_last_update() != surf_get_clock())
+    model_->get_action_heap().remove(this);
   XBT_OUT();
 }
 
@@ -117,28 +117,28 @@ void Action::ref()
 void Action::set_max_duration(double duration)
 {
   max_duration_ = duration;
-  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) // remove action from the heap
-    get_model()->get_action_heap().remove(this);
+  if (model_->is_update_lazy()) // remove action from the heap
+    model_->get_action_heap().remove(this);
 }
 
 void Action::set_sharing_penalty(double sharing_penalty)
 {
   XBT_IN("(%p,%g)", this, sharing_penalty);
   sharing_penalty_ = sharing_penalty;
-  get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), sharing_penalty);
+  model_->get_maxmin_system()->update_variable_penalty(get_variable(), sharing_penalty);
 
-  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY)
-    get_model()->get_action_heap().remove(this);
+  if (model_->is_update_lazy())
+    model_->get_action_heap().remove(this);
   XBT_OUT();
 }
 
 void Action::cancel()
 {
   set_state(Action::State::FAILED);
-  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) {
+  if (model_->is_update_lazy()) {
     if (modified_set_hook_.is_linked())
-      xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
-    get_model()->get_action_heap().remove(this);
+      xbt::intrusive_erase(*model_->get_modified_set(), *this);
+    model_->get_action_heap().remove(this);
   }
 }
 
@@ -156,10 +156,10 @@ void Action::suspend()
 {
   XBT_IN("(%p)", this);
   if (suspended_ != SuspendStates::SLEEPING) {
-    get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), 0.0);
-    if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) {
-      get_model()->get_action_heap().remove(this);
-      if (state_set_ == get_model()->get_started_action_set() && sharing_penalty_ > 0) {
+    model_->get_maxmin_system()->update_variable_penalty(get_variable(), 0.0);
+    if (model_->is_update_lazy()) {
+      model_->get_action_heap().remove(this);
+      if (state_set_ == model_->get_started_action_set() && sharing_penalty_ > 0) {
         // If we have a lazy model, we need to update the remaining value accordingly
         update_remains_lazy(surf_get_clock());
       }
@@ -173,10 +173,10 @@ void Action::resume()
 {
   XBT_IN("(%p)", this);
   if (suspended_ != SuspendStates::SLEEPING) {
-    get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), get_sharing_penalty());
+    model_->get_maxmin_system()->update_variable_penalty(get_variable(), get_sharing_penalty());
     suspended_ = SuspendStates::RUNNING;
-    if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY)
-      get_model()->get_action_heap().remove(this);
+    if (model_->is_update_lazy())
+      model_->get_action_heap().remove(this);
   }
   XBT_OUT();
 }
@@ -185,7 +185,7 @@ double Action::get_remains()
 {
   XBT_IN("(%p)", this);
   /* update remains before returning it */
-  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) /* update remains before return it */
+  if (model_->is_update_lazy()) /* update remains before return it */
     update_remains_lazy(surf_get_clock());
   XBT_OUT();
   return remains_;