-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
: 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);
}
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)
{
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();
}
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);
}
}
{
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());
}
{
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();
}
{
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_;