}
/* add in action heap */
if (min_finish > NO_MAX_DURATION)
- action.heapUpdate(model()->getActionHeap(), min_finish, NOTSET);
+ action.heapUpdate(model()->getActionHeap(), min_finish, Action::Type::NOTSET);
else
action.heapRemove(model()->getActionHeap());
min_finish = getFinishTime();
/* add in action heap */
- heapUpdate(getModel()->getActionHeap(), min_finish, NOTSET);
+ heapUpdate(getModel()->getActionHeap(), min_finish, Action::Type::NOTSET);
XBT_OUT();
}
}
// if I am wearing a latency hat
- if (action->getHat() == LATENCY) {
+ if (action->getHat() == Action::Type::LATENCY) {
XBT_DEBUG("Latency paid for action %p. Activating", action);
maxminSystem_->update_variable_weight(action->getVariable(), action->weight_);
action->heapRemove(getActionHeap());
action->refreshLastUpdate();
// if I am wearing a max_duration or normal hat
- } else if (action->getHat() == MAX_DURATION || action->getHat() == NORMAL) {
- // no need to communicate anymore
- // assume that flows that reached max_duration have remaining of 0
+ } else if (action->getHat() == Action::Type::MAX_DURATION || action->getHat() == Action::Type::NORMAL) {
+ // no need to communicate anymore
+ // assume that flows that reached max_duration have remaining of 0
XBT_DEBUG("Action %p finished", action);
action->setRemains(0);
action->finish(Action::State::done);
if (getUpdateMechanism() == UM_LAZY) {
// add to the heap the event when the latency is payed
XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->getLastUpdate());
- action->heapInsert(getActionHeap(), action->latency_ + action->getLastUpdate(), route.empty() ? NORMAL : LATENCY);
+ action->heapInsert(getActionHeap(), action->latency_ + action->getLastUpdate(),
+ route.empty() ? Action::Type::NORMAL : Action::Type::LATENCY);
}
} else
action->setVariable(maxminSystem_->variable_new(action, 1.0, -1.0, constraints_per_variable));
continue;
/* bogus priority, skip it */
- if (action->getPriority() <= 0 || action->getHat()==LATENCY)
+ if (action->getPriority() <= 0 || action->getHat() == Action::Type::LATENCY)
continue;
action->updateRemainingLazy(now);
action->getMaxDuration());
if (min > -1) {
- action->heapUpdate(actionHeap_, min, max_dur_flag ? MAX_DURATION : NORMAL);
+ action->heapUpdate(actionHeap_, min, max_dur_flag ? Action::Type::MAX_DURATION : Action::Type::NORMAL);
XBT_DEBUG("Insert at heap action(%p) min %f now %f", action, min, now);
} else
DIE_IMPOSSIBLE;
* LATENCY = this is a heap entry to warn us when the latency is payed
* MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
*/
-void Action::heapInsert(heap_type& heap, double key, enum heap_action_type hat)
+void Action::heapInsert(heap_type& heap, double key, Action::Type hat)
{
hat_ = hat;
heapHandle_ = heap.emplace(std::make_pair(key, this));
void Action::heapRemove(heap_type& heap)
{
- hat_ = NOTSET;
+ hat_ = Action::Type::NOTSET;
if (heapHandle_) {
heap.erase(*heapHandle_);
clearHeapHandle();
}
}
-void Action::heapUpdate(heap_type& heap, double key, enum heap_action_type hat)
+void Action::heapUpdate(heap_type& heap, double key, Action::Type hat)
{
hat_ = hat;
if (heapHandle_) {
int XBT_PRIVATE __surf_is_absolute_file_path(const char *file_path);
-/***********
- * Classes *
- ***********/
-
-enum heap_action_type{
- LATENCY = 100,
- MAX_DURATION,
- NORMAL,
- NOTSET
-};
-
/**********
* Action *
**********/
sleeping
};
+ enum class Type { LATENCY = 100, MAX_DURATION, NORMAL, NOTSET };
+
/**
* @brief Action constructor
*
double lastUpdate_ = 0;
double lastValue_ = 0;
lmm_variable_t variable_ = nullptr;
- enum heap_action_type hat_ = NOTSET;
+ Action::Type hat_ = Action::Type::NOTSET;
boost::optional<heap_type::handle_type> heapHandle_ = boost::none;
public:
virtual void updateRemainingLazy(double now) { THROW_IMPOSSIBLE; };
- void heapInsert(heap_type& heap, double key, enum heap_action_type hat);
+ void heapInsert(heap_type & heap, double key, Action::Type hat);
void heapRemove(heap_type& heap);
- void heapUpdate(heap_type& heap, double key, enum heap_action_type hat);
+ void heapUpdate(heap_type & heap, double key, Action::Type hat);
void clearHeapHandle() { heapHandle_ = boost::none; }
lmm_variable_t getVariable() const { return variable_; }
void setVariable(lmm_variable_t var) { variable_ = var; }
void refreshLastUpdate() {lastUpdate_ = surf_get_clock();}
double getLastValue() const { return lastValue_; }
void setLastValue(double val) { lastValue_ = val; }
- enum heap_action_type getHat() const { return hat_; }
+ Action::Type getHat() const { return hat_; }
bool is_linked() const { return action_lmm_hook.is_linked(); }
protected:
Action::SuspendStates suspended_ = Action::SuspendStates::not_suspended;