// FIXME: sleep variables should not consume 1.0 in System::expand()
action->setMaxDuration(duration);
- action->suspended_ = 2;
+ action->suspended_ = Action::SuspendStates::sleeping;
if (duration < 0) { // NO_MAX_DURATION
/* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */
simgrid::xbt::intrusive_erase(*action->getStateSet(), *action);
continue;
/* action suspended, skip it */
- if (action.suspended_ != 0)
+ if (action.suspended_ != Action::SuspendStates::not_suspended)
continue;
sum_priority += 1.0 / action.getPriority();
continue;
/* verify if the action is really running on cpu */
- if (action.suspended_ == 0 && action.getPriority() > 0) {
+ if (action.suspended_ == Action::SuspendStates::not_suspended && action.getPriority() > 0) {
/* total area needed to finish the action. Used in trace integration */
total_area = (action.getRemains()) * sum_priority * action.getPriority();
continue;
/* action suspended, skip it */
- if (action.suspended_ != 0)
+ if (action.suspended_ != Action::SuspendStates::not_suspended)
continue;
/* action don't need update */
CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(model()), 1.0, isOff(), this);
action->setMaxDuration(duration);
- action->suspended_ = 2;
+ action->suspended_ = Action::SuspendStates::sleeping;
if (duration == NO_MAX_DURATION) {
/* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */
simgrid::xbt::intrusive_erase(*action->getStateSet(), *action);
void CpuTiAction::suspend()
{
XBT_IN("(%p)", this);
- if (suspended_ != 2) {
- suspended_ = 1;
+ if (suspended_ != Action::SuspendStates::sleeping) {
+ suspended_ = Action::SuspendStates::suspended;
heapRemove(getModel()->getActionHeap());
cpu_->modified(true);
}
void CpuTiAction::resume()
{
XBT_IN("(%p)", this);
- if (suspended_ != 2) {
- suspended_ = 0;
+ if (suspended_ != Action::SuspendStates::sleeping) {
+ suspended_ = Action::SuspendStates::not_suspended;
cpu_->modified(true);
}
XBT_OUT();
void NetworkCm02Action::updateRemainingLazy(double now)
{
- if (suspended_ != 0)
+ if (suspended_ != Action::SuspendStates::not_suspended)
return;
double delta = now - getLastUpdate();
{
L07Action *action = static_cast<L07Action*>(execution_start(1.0));
action->setMaxDuration(duration);
- action->suspended_ = 2;
+ action->suspended_ = Action::SuspendStates::sleeping;
model()->getMaxminSystem()->update_variable_weight(action->getVariable(), 0.0);
return action;
}
double lat_bound = sg_tcp_gamma / (2.0 * lat_current);
XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
- if ((latency_ <= 0.0) && (suspended_ == 0)) {
+ if ((latency_ <= 0.0) && (suspended_ == Action::SuspendStates::not_suspended)) {
if (rate_ < 0)
getModel()->getMaxminSystem()->update_variable_bound(getVariable(), lat_bound);
else
void StorageN11Action::suspend()
{
XBT_IN("(%p)", this);
- if (suspended_ != 2) {
+ if (suspended_ != Action::SuspendStates::sleeping) {
getModel()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
- suspended_ = 1;
+ suspended_ = Action::SuspendStates::suspended;
}
XBT_OUT();
}
bool StorageN11Action::isSuspended()
{
- return suspended_ == 1;
+ return suspended_ == Action::SuspendStates::suspended;
}
void StorageN11Action::setMaxDuration(double /*duration*/)
void Action::suspend()
{
XBT_IN("(%p)", this);
- if (suspended_ != 2) {
+ if (suspended_ != SuspendStates::sleeping) {
getModel()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
if (getModel()->getUpdateMechanism() == UM_LAZY){
heapRemove(getModel()->getActionHeap());
updateRemainingLazy(surf_get_clock());
}
}
- suspended_ = 1;
+ suspended_ = SuspendStates::suspended;
}
XBT_OUT();
}
void Action::resume()
{
XBT_IN("(%p)", this);
- if (suspended_ != 2) {
+ if (suspended_ != SuspendStates::sleeping) {
getModel()->getMaxminSystem()->update_variable_weight(getVariable(), getPriority());
- suspended_ = 0;
+ suspended_ = SuspendStates::not_suspended;
if (getModel()->getUpdateMechanism() == UM_LAZY)
heapRemove(getModel()->getActionHeap());
}
bool Action::isSuspended()
{
- return suspended_ == 1;
+ return suspended_ == SuspendStates::suspended;
}
/* insert action on heap using a given key and a hat (heap_action_type)
* a hat can be of three types for communications:
not_in_the_system /**< Not in the system anymore. Why did you ask ? */
};
+ enum class SuspendStates {
+ not_suspended = 0, /**< Action currently not suspended **/
+ suspended,
+ sleeping
+ };
+
/**
* @brief Action constructor
*
enum heap_action_type getHat() const { return hat_; }
bool is_linked() const { return action_lmm_hook.is_linked(); }
protected:
- int suspended_ = 0;
+ Action::SuspendStates suspended_ = Action::SuspendStates::not_suspended;
};
typedef Action::ActionList ActionList;