Add the new state as a parameter for finish().
-/* Copyright (c) 2013-2015. The SimGrid Team.
+/* Copyright (c) 2013-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
action->getLastUpdate(), now - action->getLastUpdate());
}
- action->finish();
+ action->finish(Action::State::done);
XBT_CDEBUG(surf_kernel, "Action %p finished", action);
/* set the remains to 0 due to precision problems when updating the remaining amount */
action->setRemains(0);
- action->setState(Action::State::done);
}
if (TRACE_is_enabled()) {
//defining the last timestamp that we can safely dump to trace file
if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
}
}
}
-/* Copyright (c) 2013-2015. The SimGrid Team.
+/* Copyright (c) 2013-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
while ((xbt_heap_size(tiActionHeap_) > 0) && (xbt_heap_maxkey(tiActionHeap_) <= now)) {
CpuTiAction *action = static_cast<CpuTiAction*>(xbt_heap_pop(tiActionHeap_));
XBT_DEBUG("Action %p: finish", action);
- action->finish();
+ action->finish(Action::State::done);
/* set the remains to 0 due to precision problems when updating the remaining amount */
action->setRemains(0);
- action->setState(Action::State::done);
/* update remaining amount of all actions */
action->cpu_->updateRemainingAmount(surf_get_clock());
}
// assume that flows that reached max_duration have remaining of 0
XBT_DEBUG("Action %p finished", action);
action->setRemains(0);
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
action->heapRemove(actionHeap_);
}
}
if (((action->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
}
}
}
if ((remains_ <= 0 && (lmm_get_variable_weight(getVariable()) > 0)) ||
((maxDuration_ > NO_MAX_DURATION) && (maxDuration_ <= 0))) {
- finish();
- setState(Action::State::done);
+ finish(Action::State::done);
heapRemove(getModel()->getActionHeap());
}
if (((action->getRemainsNoUpdate() <= 0) ||
((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0)))) {
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
}
}
}
if(sgFlow->finished_){
xbt_dynar_push(socket_to_destroy,&ns3Socket);
XBT_DEBUG("Destroy socket %p of action %p", ns3Socket, action);
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
}
}
if (((action->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
} else {
/* Need to check that none of the model has failed */
int i = 0;
void *constraint_id = lmm_constraint_id(cnst);
if (static_cast<simgrid::surf::Resource*>(constraint_id)->isOff()) {
XBT_DEBUG("Action (%p) Failed!!", action);
- action->finish();
- action->setState(Action::State::failed);
+ action->finish(Action::State::failed);
break;
}
cnst = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i);
if (action->getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action->getVariable()) > 0 &&
action->storage_->usedSize_ == action->storage_->getSize()) {
- action->finish();
- action->setState(Action::State::failed);
+ action->finish(Action::State::failed);
} else if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
}
}
}
xbt_free(category_);
}
-void Action::finish() {
+void Action::finish(Action::State state)
+{
finishTime_ = surf_get_clock();
+ setState(state);
}
Action::State Action::getState()
//FIXME: duplicated code
if (((remains_ <= 0) && (lmm_get_variable_weight(getVariable()) > 0)) ||
((maxDuration_ > NO_MAX_DURATION) && (maxDuration_ <= 0))) {
- finish();
- setState(Action::State::done);
+ finish(Action::State::done);
heapRemove(getModel()->getActionHeap());
}
}
/** @brief Destructor */
virtual ~Action();
- /** @brief Mark that the action is now finished */
- void finish();
+ /**
+ * @brief Mark that the action is now finished
+ *
+ * @param state the new [state](\ref simgrid::surf::Action::State) of the current Action
+ */
+ void finish(Action::State state);
/** @brief Get the [state](\ref simgrid::surf::Action::State) of the current Action */
Action::State getState(); /**< get the state*/