#include <cfloat>
#include <cmath>
#include <cstdlib>
+#include <xbt/utility.hpp>
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_maxmin);
#define SHOW_EXPR_G(expr) XBT_DEBUG(#expr " = %g", expr);
break;
if (elem.consumption_weight > 0 && elem.variable->saturated_variable_set_hook.is_linked()) {
XBT_DEBUG("\t\tGet rid of variable %p", elem.variable);
- var_list.erase(var_list.iterator_to(*elem.variable));
+ simgrid::xbt::intrusive_erase(var_list, *elem.variable);
}
}
} else {
#include "xbt/log.h"
#include "xbt/mallocator.h"
#include "xbt/sysdep.h"
+#include "xbt/utility.hpp"
#include <algorithm>
#include <cmath>
#include <cstdlib>
for (s_lmm_element_t& elem : var->cnsts) {
if (var->sharing_weight > 0)
elem.decrease_concurrency();
- if (elem.enabled_element_set_hook.is_linked()) {
- auto& set = elem.constraint->enabled_element_set;
- set.erase(set.iterator_to(elem));
- }
- if (elem.disabled_element_set_hook.is_linked()) {
- auto& set = elem.constraint->disabled_element_set;
- set.erase(set.iterator_to(elem));
- }
- if (elem.active_element_set_hook.is_linked()) {
- auto& set = elem.constraint->active_element_set;
- set.erase(set.iterator_to(elem));
- }
+ if (elem.enabled_element_set_hook.is_linked())
+ simgrid::xbt::intrusive_erase(elem.constraint->enabled_element_set, elem);
+ if (elem.disabled_element_set_hook.is_linked())
+ simgrid::xbt::intrusive_erase(elem.constraint->disabled_element_set, elem);
+ if (elem.active_element_set_hook.is_linked())
+ simgrid::xbt::intrusive_erase(elem.constraint->active_element_set, elem);
int nelements = elem.constraint->enabled_element_set.size() + elem.constraint->disabled_element_set.size();
if (nelements == 0)
make_constraint_inactive(elem.constraint);
// Enabling the variable, move var to list head. Subtlety is: here, we need to call update_modified_set AFTER
// moving at least one element of var.
- variable_set.erase(variable_set.iterator_to(*var));
+ simgrid::xbt::intrusive_erase(variable_set, *var);
variable_set.push_front(*var);
for (s_lmm_element_t& elem : var->cnsts) {
- auto& set = elem.constraint->disabled_element_set;
- set.erase(set.iterator_to(elem));
+ simgrid::xbt::intrusive_erase(elem.constraint->disabled_element_set, elem);
elem.constraint->enabled_element_set.push_front(elem);
elem.increase_concurrency();
}
xbt_assert(not var->staged_weight, "Staged weight should have been cleared");
// Disabling the variable, move to var to list tail. Subtlety is: here, we need to call update_modified_set
// BEFORE moving the last element of var.
- variable_set.erase(variable_set.iterator_to(*var));
+ simgrid::xbt::intrusive_erase(variable_set, *var);
variable_set.push_back(*var);
if (not var->cnsts.empty())
update_modified_set(var->cnsts[0].constraint);
for (s_lmm_element_t& elem : var->cnsts) {
- auto& set = elem.constraint->enabled_element_set;
- set.erase(set.iterator_to(elem));
+ simgrid::xbt::intrusive_erase(elem.constraint->enabled_element_set, elem);
elem.constraint->disabled_element_set.push_back(elem);
- if (elem.active_element_set_hook.is_linked()) {
- auto& set = elem.constraint->active_element_set;
- set.erase(set.iterator_to(elem));
- }
+ if (elem.active_element_set_hook.is_linked())
+ simgrid::xbt::intrusive_erase(elem.constraint->active_element_set, elem);
elem.decrease_concurrency();
}
#include "xbt/asserts.h"
#include "xbt/mallocator.h"
#include "xbt/misc.h"
+#include "xbt/utility.hpp"
#include <boost/intrusive/list.hpp>
#include <cmath>
#include <limits>
}
inline void s_lmm_element_t::make_inactive()
{
- if (active_element_set_hook.is_linked()) {
- auto& set = constraint->active_element_set;
- set.erase(set.iterator_to(*this));
- }
+ if (active_element_set_hook.is_linked())
+ simgrid::xbt::intrusive_erase(constraint->active_element_set, *this);
}
/**
void remove_variable(lmm_variable_t var)
{
if (var->variable_set_hook.is_linked())
- variable_set.erase(variable_set.iterator_to(*var));
+ simgrid::xbt::intrusive_erase(variable_set, *var);
if (var->saturated_variable_set_hook.is_linked())
- saturated_variable_set.erase(saturated_variable_set.iterator_to(*var));
+ simgrid::xbt::intrusive_erase(saturated_variable_set, *var);
}
void make_constraint_active(lmm_constraint_t cnst)
{
void make_constraint_inactive(lmm_constraint_t cnst)
{
if (cnst->active_constraint_set_hook.is_linked())
- active_constraint_set.erase(active_constraint_set.iterator_to(*cnst));
+ simgrid::xbt::intrusive_erase(active_constraint_set, *cnst);
if (cnst->modified_constraint_set_hook.is_linked())
- modified_constraint_set.erase(modified_constraint_set.iterator_to(*cnst));
+ simgrid::xbt::intrusive_erase(modified_constraint_set, *cnst);
}
void enable_var(lmm_variable_t var);
#include "xbt/functional.hpp"
#include "xbt/log.h"
#include "xbt/sysdep.h"
+#include "xbt/utility.hpp"
#include "simgrid/s4u/Host.hpp"
XBT_DEBUG("%p should not be run anymore",process);
simix_global->process_list.erase(process->pid);
- if (process->host && process->host_process_list_hook.is_linked()) {
- auto& list = process->host->extension<simgrid::simix::Host>()->process_list;
- list.erase(list.iterator_to(*process));
- }
+ if (process->host && process->host_process_list_hook.is_linked())
+ simgrid::xbt::intrusive_erase(process->host->extension<simgrid::simix::Host>()->process_list, *process);
xbt_swag_insert(process, simix_global->process_to_destroy);
process->context->iwannadie = 0;
void SIMIX_process_change_host(smx_actor_t process, sg_host_t dest)
{
xbt_assert((process != nullptr), "Invalid parameters");
- auto& list = process->host->extension<simgrid::simix::Host>()->process_list;
- list.erase(list.iterator_to(*process));
+ simgrid::xbt::intrusive_erase(process->host->extension<simgrid::simix::Host>()->process_list, *process);
process->host = dest;
dest->extension<simgrid::simix::Host>()->process_list.push_back(*process);
}
#include "cpu_ti.hpp"
#include "simgrid/sg_config.h"
#include "src/kernel/lmm/maxmin.hpp"
+#include "xbt/utility.hpp"
#include <algorithm>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf_cpu, "Logging specific to the SURF CPU IMPROVED module");
action->suspended_ = 2;
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 */
- action->getStateSet()->erase(action->getStateSet()->iterator_to(*action));
+ simgrid::xbt::intrusive_erase(*action->getStateSet(), *action);
action->stateSet_ = static_cast<CpuCas01Model*>(model())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
action->getStateSet()->push_back(*action);
}
#include "cpu_ti.hpp"
#include "src/surf/trace_mgr.hpp"
+#include "xbt/utility.hpp"
#include <algorithm>
#ifndef SURF_MODEL_CPUTI_H_
action->setMaxDuration(duration);
action->suspended_ = 2;
if (duration == NO_MAX_DURATION) {
- /* Move to the *end* of the corresponding action set. This convention
- is used to speed up update_resource_state */
- action->getStateSet()->erase(action->getStateSet()->iterator_to(*action));
- action->stateSet_ = static_cast<CpuTiModel*>(model())->runningActionSetThatDoesNotNeedBeingChecked_;
- action->getStateSet()->push_back(*action);
+ /* 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);
+ action->stateSet_ = static_cast<CpuTiModel*>(model())->runningActionSetThatDoesNotNeedBeingChecked_;
+ action->getStateSet()->push_back(*action);
}
actionSet_->push_back(*action);
modifiedCpu->push_back(*this);
}
} else {
- if (cpu_ti_hook.is_linked()) {
- modifiedCpu->erase(modifiedCpu->iterator_to(*this));
- }
+ if (cpu_ti_hook.is_linked())
+ simgrid::xbt::intrusive_erase(*modifiedCpu, *this);
}
}
refcount_--;
if (not refcount_) {
if (action_hook.is_linked())
- getStateSet()->erase(getStateSet()->iterator_to(*this));
+ simgrid::xbt::intrusive_erase(*getStateSet(), *this);
/* remove from action_set */
if (action_ti_hook.is_linked())
- cpu_->actionSet_->erase(cpu_->actionSet_->iterator_to(*this));
+ simgrid::xbt::intrusive_erase(*cpu_->actionSet_, *this);
/* remove from heap */
heapRemove(getModel()->getActionHeap());
cpu_->modified(true);
#include "xbt/config.hpp"
#include "xbt/string.hpp"
+#include "xbt/utility.hpp"
#include "ns3/core-module.h"
#include "ns3/node.h"
refcount_--;
if (not refcount_) {
if (action_hook.is_linked())
- stateSet_->erase(stateSet_->iterator_to(*this));
+ simgrid::xbt::intrusive_erase(*stateSet_, *this);
XBT_DEBUG ("Removing action %p", this);
delete this;
return 1;
#include "ptask_L07.hpp"
#include "cpu_interface.hpp"
+#include "xbt/utility.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_host);
XBT_LOG_EXTERNAL_CATEGORY(xbt_cfg);
refcount_--;
if (not refcount_) {
if (action_hook.is_linked())
- stateSet_->erase(stateSet_->iterator_to(*this));
+ simgrid::xbt::intrusive_erase(*stateSet_, *this);
if (getVariable())
getModel()->getMaxminSystem()->variable_free(getVariable());
delete this;
#include "simgrid/s4u/Engine.hpp"
#include "src/kernel/lmm/maxmin.hpp"
#include "src/kernel/routing/NetPoint.hpp"
+#include "xbt/utility.hpp"
#include <cmath> /*ceil*/
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_storage);
refcount_--;
if (not refcount_) {
if (action_hook.is_linked())
- stateSet_->erase(stateSet_->iterator_to(*this));
+ simgrid::xbt::intrusive_erase(*stateSet_, *this);
if (getVariable())
getModel()->getMaxminSystem()->variable_free(getVariable());
xbt_free(getCategory());
#include "src/instr/instr_private.hpp" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
#include "src/kernel/routing/NetPoint.hpp"
#include "src/surf/HostImpl.hpp"
+#include "xbt/utility.hpp"
#include <fstream>
#include <set>
void Action::setState(Action::State state)
{
- stateSet_->erase(stateSet_->iterator_to(*this));
+ simgrid::xbt::intrusive_erase(*stateSet_, *this);
switch (state) {
case Action::State::ready:
stateSet_ = model_->getReadyActionSet();
setState(Action::State::failed);
if (getModel()->getUpdateMechanism() == UM_LAZY) {
if (action_lmm_hook.is_linked())
- getModel()->getModifiedSet()->erase(getModel()->getModifiedSet()->iterator_to(*this));
+ simgrid::xbt::intrusive_erase(*getModel()->getModifiedSet(), *this);
heapRemove(getModel()->getActionHeap());
}
}
refcount_--;
if (not refcount_) {
if (action_hook.is_linked())
- stateSet_->erase(stateSet_->iterator_to(*this));
+ simgrid::xbt::intrusive_erase(*stateSet_, *this);
if (getVariable())
getModel()->getMaxminSystem()->variable_free(getVariable());
if (getModel()->getUpdateMechanism() == UM_LAZY) {
/* remove from heap */
heapRemove(getModel()->getActionHeap());
if (action_lmm_hook.is_linked())
- getModel()->getModifiedSet()->erase(getModel()->getModifiedSet()->iterator_to(*this));
+ simgrid::xbt::intrusive_erase(*getModel()->getModifiedSet(), *this);
}
delete this;
return 1;