namespace kernel {
namespace resource {
-typedef std::pair<double, simgrid::kernel::resource::Action*> heap_element_type;
+typedef std::pair<double, Action*> heap_element_type;
typedef boost::heap::pairing_heap<heap_element_type, boost::heap::constant_time_size<false>, boost::heap::stable<true>,
boost::heap::compare<simgrid::xbt::HeapComparator<heap_element_type>>>
heap_type;
-typedef std::pair<double, simgrid::kernel::resource::Action*> heap_element_type;
+typedef std::pair<double, Action*> heap_element_type;
class XBT_PUBLIC ActionHeap : public heap_type {
friend Action;
std::string category_; /**< tracing category for categorized resource utilization monitoring */
double cost_;
- simgrid::kernel::resource::Model* model_;
+ Model* model_;
void* data_ = nullptr; /**< for your convenience */
activity::ActivityImpl* activity_ = nullptr;
/* LMM */
- double last_update_ = 0;
- double last_value_ = 0;
- kernel::lmm::Variable* variable_ = nullptr;
+ double last_update_ = 0;
+ double last_value_ = 0;
+ lmm::Variable* variable_ = nullptr;
ActionHeap::Type type_ = ActionHeap::Type::unset;
boost::optional<ActionHeap::handle_type> heap_hook_ = boost::none;
Model(const Model&) = delete;
Model& operator=(const Model&) = delete;
- virtual ~Model();
+ virtual ~Model() = default;
/** @brief Get the set of [actions](@ref Action) in *inited* state */
Action::StateSet* get_inited_action_set() { return &inited_action_set_; }
* @details This is the ancestor class of every resources in SimGrid, such as links, CPU or storage
*/
class XBT_PUBLIC Resource {
+ std::string name_;
+ Model* model_;
+ bool is_on_ = true;
+
+ lmm::Constraint* const constraint_;
+
+protected:
+ struct Metric {
+ double peak; /**< The peak of the metric, ie its max value */
+ double scale; /**< Current availability of the metric according to the profiles, in [0,1] */
+ profile::Event* event; /**< The associated profile event associated to the metric */
+ };
+
public:
/**
* @brief Constructor of LMM Resources
{
}
- virtual ~Resource();
+ virtual ~Resource() = default;
/** @brief Get the Model of the current Resource */
Model* get_model() const { return model_; }
/** @brief setup the profile file with states events (ON or OFF). The profile must contain boolean values. */
virtual void set_state_profile(profile::Profile* profile);
-private:
- std::string name_;
- Model* model_;
- bool is_on_ = true;
-
-public: /* LMM */
/** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */
lmm::Constraint* get_constraint() const { return constraint_; }
-private:
- kernel::lmm::Constraint* const constraint_;
-
-public:
profile::Event* state_event_ = nullptr;
-
-protected:
- struct Metric {
- double peak; /**< The peak of the metric, ie its max value */
- double scale; /**< Current availability of the metric according to the profiles, in [0,1] */
- profile::Event* event; /**< The associated profile event associated to the metric */
- };
};
} // namespace resource
} // namespace kernel
set_state(Action::State::FAILED);
if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) {
if (modified_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
+ xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
get_model()->get_action_heap().remove(this);
}
}
if (max_duration_ != NO_MAX_DURATION)
double_update(&max_duration_, delta, sg_surf_precision);
}
+
void Action::update_remains(double delta)
{
double_update(&remains_, delta, sg_maxmin_precision * sg_surf_precision);
{
return top().first;
}
+
void ActionHeap::insert(Action* action, double date, ActionHeap::Type type)
{
action->type_ = type;
action->heap_hook_ = emplace(std::make_pair(date, action));
}
+
void ActionHeap::remove(Action* action)
{
action->type_ = ActionHeap::Type::unset;
action->heap_hook_ = boost::none;
}
}
+
void ActionHeap::update(Action* action, double date, ActionHeap::Type type)
{
action->type_ = type;
action->heap_hook_ = emplace(std::make_pair(date, action));
}
}
+
Action* ActionHeap::pop()
{
Action* action = top().second;
namespace resource {
Model::Model(Model::UpdateAlgo algo) : update_algorithm_(algo) {}
-Model::~Model() = default;
Action::ModifiedSet* Model::get_modified_set() const
{
{
if (list->empty())
return nullptr;
- simgrid::kernel::resource::Action* res = &list->front();
+ Action* res = &list->front();
list->pop_front();
return res;
}
namespace kernel {
namespace resource {
-Resource::~Resource() = default;
-
double Resource::get_load() const
{
return constraint_->get_usage();