boost::optional<heap_type::handle_type> heap_hook_ = boost::none;
public:
- void heapInsert(heap_type& heap, double key, Action::Type hat);
- void heapRemove(heap_type& heap);
- void heapUpdate(heap_type& heap, double key, Action::Type hat);
+ void heapInsert(double key, Action::Type hat);
+ void heapRemove();
+ void heapUpdate(double key, Action::Type hat);
void clearHeapHandle() { heap_hook_ = boost::none; }
lmm::Variable* get_variable() const { return variable_; }
get_model()->getMaxminSystem()->variable_free(get_variable());
if (get_model()->getUpdateMechanism() == UM_LAZY) {
/* remove from heap */
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
if (modified_set_hook_.is_linked())
simgrid::xbt::intrusive_erase(*get_model()->getModifiedSet(), *this);
}
get_model()->getMaxminSystem()->update_variable_bound(variable_, bound);
if (get_model()->getUpdateMechanism() == UM_LAZY && get_last_update() != surf_get_clock())
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
XBT_OUT();
}
{
max_duration_ = duration;
if (get_model()->getUpdateMechanism() == UM_LAZY) // remove action from the heap
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
}
void Action::set_priority(double weight)
get_model()->getMaxminSystem()->update_variable_weight(get_variable(), weight);
if (get_model()->getUpdateMechanism() == UM_LAZY)
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
XBT_OUT();
}
if (get_model()->getUpdateMechanism() == UM_LAZY) {
if (modified_set_hook_.is_linked())
simgrid::xbt::intrusive_erase(*get_model()->getModifiedSet(), *this);
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
}
}
if (suspended_ != SuspendStates::sleeping) {
get_model()->getMaxminSystem()->update_variable_weight(get_variable(), 0.0);
if (get_model()->getUpdateMechanism() == UM_LAZY) {
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
if (state_set_ == get_model()->getRunningActionSet() && sharing_priority_ > 0) {
// If we have a lazy model, we need to update the remaining value accordingly
update_remains_lazy(surf_get_clock());
get_model()->getMaxminSystem()->update_variable_weight(get_variable(), get_priority());
suspended_ = SuspendStates::not_suspended;
if (get_model()->getUpdateMechanism() == UM_LAZY)
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
}
XBT_OUT();
}
* 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, Action::Type hat)
+void Action::heapInsert(double key, Action::Type hat)
{
type_ = hat;
- heap_hook_ = heap.emplace(std::make_pair(key, this));
+ heap_hook_ = get_model()->getActionHeap().emplace(std::make_pair(key, this));
}
-void Action::heapRemove(heap_type& heap)
+void Action::heapRemove()
{
type_ = Action::Type::NOTSET;
if (heap_hook_) {
- heap.erase(*heap_hook_);
+ get_model()->getActionHeap().erase(*heap_hook_);
clearHeapHandle();
}
}
-void Action::heapUpdate(heap_type& heap, double key, Action::Type hat)
+void Action::heapUpdate(double key, Action::Type hat)
{
type_ = hat;
if (heap_hook_) {
- heap.update(*heap_hook_, std::make_pair(key, this));
+ get_model()->getActionHeap().update(*heap_hook_, std::make_pair(key, this));
} else {
- heap_hook_ = heap.emplace(std::make_pair(key, this));
+ heap_hook_ = get_model()->getActionHeap().emplace(std::make_pair(key, this));
}
}
action->get_start_time(), min, share, action->get_max_duration());
if (min > -1) {
- action->heapUpdate(action_heap_, min, max_dur_flag ? Action::Type::MAX_DURATION : Action::Type::NORMAL);
+ action->heapUpdate(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;
model()->getMaxminSystem()->update_variable_weight(action->get_variable(), 0.0);
if (model()->getUpdateMechanism() == UM_LAZY) { // remove action from the heap
- action->heapRemove(model()->getActionHeap());
+ action->heapRemove();
// this is necessary for a variable with weight 0 since such variables are ignored in lmm and we need to set its
// max_duration correctly at the next call to share_resources
model()->getModifiedSet()->push_front(*action);
action.get_state() == kernel::resource::Action::State::not_in_the_system) {
action.set_finish_time(date);
action.set_state(kernel::resource::Action::State::failed);
- action.heapRemove(model()->getActionHeap());
+ action.heapRemove();
}
}
}
}
/* add in action heap */
if (min_finish > NO_MAX_DURATION)
- action.heapUpdate(model()->getActionHeap(), min_finish, kernel::resource::Action::Type::NOTSET);
+ action.heapUpdate(min_finish, kernel::resource::Action::Type::NOTSET);
else
- action.heapRemove(model()->getActionHeap());
+ action.heapRemove();
XBT_DEBUG("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f", getCname(),
&action, action.get_start_time(), action.get_finish_time(), action.get_max_duration());
if (action_ti_hook.is_linked())
simgrid::xbt::intrusive_erase(cpu_->actionSet_, *this);
/* remove from heap */
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
cpu_->modified(true);
}
void CpuTiAction::cancel()
{
this->set_state(Action::State::failed);
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
cpu_->modified(true);
}
XBT_IN("(%p)", this);
if (suspended_ != Action::SuspendStates::sleeping) {
suspended_ = Action::SuspendStates::suspended;
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
cpu_->modified(true);
}
XBT_OUT();
min_finish = get_finish_time();
/* add in action heap */
- heapUpdate(get_model()->getActionHeap(), min_finish, Action::Type::NOTSET);
+ heapUpdate(min_finish, Action::Type::NOTSET);
XBT_OUT();
}
if (action->get_type() == kernel::resource::Action::Type::LATENCY) {
XBT_DEBUG("Latency paid for action %p. Activating", action);
maxmin_system_->update_variable_weight(action->get_variable(), action->weight_);
- action->heapRemove(getActionHeap());
+ action->heapRemove();
action->set_last_update();
// if I am wearing a max_duration or normal hat
// assume that flows that reached max_duration have remaining of 0
XBT_DEBUG("Action %p finished", action);
action->finish(kernel::resource::Action::State::done);
- action->heapRemove(getActionHeap());
+ action->heapRemove();
}
}
}
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->get_last_update());
- action->heapInsert(getActionHeap(), action->latency_ + action->get_last_update(),
- route.empty() ? kernel::resource::Action::Type::NORMAL
- : kernel::resource::Action::Type::LATENCY);
+ action->heapInsert(action->latency_ + action->get_last_update(), route.empty()
+ ? kernel::resource::Action::Type::NORMAL
+ : kernel::resource::Action::Type::LATENCY);
}
} else
action->set_variable(maxmin_system_->variable_new(action, 1.0, -1.0, constraints_per_variable));
if ((get_remains_no_update() <= 0 && (get_variable()->get_weight() > 0)) ||
((max_duration > NO_MAX_DURATION) && (max_duration <= 0))) {
finish(Action::State::done);
- heapRemove(get_model()->getActionHeap());
+ heapRemove();
}
set_last_update();