- if (updateMechanism_ == UM_FULL)
- updateActionsStateFull(now, delta);
- else if (updateMechanism_ == UM_LAZY)
- updateActionsStateLazy(now, delta);
- else
- xbt_die("Invalid cpu update mechanism!");
-}
-
-void Model::updateActionsStateLazy(double /*now*/, double /*delta*/)
-{
- THROW_UNIMPLEMENTED;
-}
-
-void Model::updateActionsStateFull(double /*now*/, double /*delta*/)
-{
- THROW_UNIMPLEMENTED;
-}
-
-}
-}
-
-/************
- * Resource *
- ************/
-
-namespace simgrid {
-namespace surf {
-
-Resource::Resource(Model *model, const char *name)
- : name_(xbt_strdup(name))
- , model_(model)
-{}
-
-Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint)
- : name_(xbt_strdup(name))
- , model_(model)
- , constraint_(constraint)
-{}
-
-Resource::~Resource() {
- xbt_free((void*)name_);
-}
-
-bool Resource::isOn() const {
- return isOn_;
-}
-bool Resource::isOff() const {
- return ! isOn_;
-}
-
-void Resource::turnOn()
-{
- isOn_ = true;
-}
-
-void Resource::turnOff()
-{
- isOn_ = false;
-}
-
-Model *Resource::getModel() const {
- return model_;
-}
-
-const char *Resource::getName() const {
- return name_;
-}
-
-bool Resource::operator==(const Resource &other) const {
- return strcmp(name_, other.name_);
-}
-
-lmm_constraint_t Resource::getConstraint() const {
- return constraint_;
-}
-
-}
-}
-
-/**********
- * Action *
- **********/
-
-const char *surf_action_state_names[6] = {
- "SURF_ACTION_READY",
- "SURF_ACTION_RUNNING",
- "SURF_ACTION_FAILED",
- "SURF_ACTION_DONE",
- "SURF_ACTION_TO_FREE",
- "SURF_ACTION_NOT_IN_THE_SYSTEM"
-};
-
-/* added to manage the communication action's heap */
-void surf_action_lmm_update_index_heap(void *action, int i) {
- static_cast<simgrid::surf::Action*>(action)->updateIndexHeap(i);
-}
-
-namespace simgrid {
-namespace surf {
-
-void Action::initialize(simgrid::surf::Model *model, double cost, bool failed,
- lmm_variable_t var)
-{
- remains_ = cost;
- start_ = surf_get_clock();
- cost_ = cost;
- model_ = model;
- variable_ = var;
- if (failed)
- stateSet_ = getModel()->getFailedActionSet();
- else
- stateSet_ = getModel()->getRunningActionSet();
-
- stateSet_->push_back(*this);
-}
-
-Action::Action(simgrid::surf::Model *model, double cost, bool failed)
-{
- initialize(model, cost, failed);
-}
-
-Action::Action(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var)
-{
- initialize(model, cost, failed, var);
-}
-
-Action::~Action() {
- xbt_free(category_);
-}
-
-void Action::finish() {
- finishTime_ = surf_get_clock();
-}
-
-Action::State Action::getState()
-{
- if (stateSet_ == getModel()->getReadyActionSet())
- return Action::State::ready;
- if (stateSet_ == getModel()->getRunningActionSet())
- return Action::State::running;
- if (stateSet_ == getModel()->getFailedActionSet())
- return Action::State::failed;
- if (stateSet_ == getModel()->getDoneActionSet())
- return Action::State::done;
- return Action::State::not_in_the_system;
-}
-
-void Action::setState(Action::State state)
-{
- stateSet_->erase(stateSet_->iterator_to(*this));
- switch (state) {
- case Action::State::ready:
- stateSet_ = getModel()->getReadyActionSet();
- break;
- case Action::State::running:
- stateSet_ = getModel()->getRunningActionSet();
- break;
- case Action::State::failed:
- stateSet_ = getModel()->getFailedActionSet();
- break;
- case Action::State::done:
- stateSet_ = getModel()->getDoneActionSet();
- break;
- default:
- stateSet_ = nullptr;
- break;
- }
- if (stateSet_)
- stateSet_->push_back(*this);
-}
-
-double Action::getBound()
-{
- return (variable_) ? lmm_variable_getbound(variable_) : 0;
-}
-
-void Action::setBound(double bound)
-{
- XBT_IN("(%p,%g)", this, bound);
- if (variable_)
- lmm_update_variable_bound(getModel()->getMaxminSystem(), variable_, bound);
-
- if (getModel()->getUpdateMechanism() == UM_LAZY && getLastUpdate()!=surf_get_clock())
- heapRemove(getModel()->getActionHeap());
- XBT_OUT();
-}
-
-double Action::getStartTime()
-{
- return start_;
-}
-
-double Action::getFinishTime()
-{
- /* keep the function behavior, some models (cpu_ti) change the finish time before the action end */
- return remains_ == 0 ? finishTime_ : -1;
-}
-
-void Action::setData(void* data)
-{
- data_ = data;