class XBT_PUBLIC Resource {
std::string name_ = "unnamed";
bool is_on_ = true;
+ bool sealed_ = false;
protected:
struct Metric {
public:
Resource(const std::string& name) : name_(name){};
virtual ~Resource() = default;
+ virtual void seal() { sealed_ = true; }
/** @brief Get the name of the current Resource */
const std::string& get_name() const { return name_; }
/** @brief Check if the current Resource is active */
virtual bool is_on() const { return is_on_; }
+ virtual bool is_sealed() const { return sealed_; }
+
/** @brief Turn on the current Resource */
virtual void turn_on() { is_on_ = true; }
/** @brief Turn off the current Resource */
->set_write_constraint(maxmin_system->constraint_new(this, write_bw_))
->set_constraint(maxmin_system->constraint_new(this, std::max(read_bw_, write_bw_)));
XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw_, write_bw_);
+ Resource::seal();
turn_on();
}
xbt::signal<void(DiskAction const&, Action::State, Action::State)> DiskAction::on_state_change;
Cpu* Cpu::set_core_count(int core_count)
{
+ xbt_assert(not is_sealed(), "Core count cannot be changed once CPU has been sealed");
xbt_assert(core_count > 0, "Host %s must have at least one core, not 0.", piface_->get_cname());
core_count_ = core_count;
return this;
speed_.event = profile->schedule(&profile::future_evt_set, this);
}
+void Cpu::seal()
+{
+ Resource::seal();
+}
+
/**********
* Action *
**********/
Cpu* set_core_count(int core_count);
virtual int get_core_count();
+ void seal();
+
/** @brief Get a forecast of the speed (in flops/s) if the load were as provided.
*
* The provided load should encompasses both the application's activities and the external load that come from a
}
}
}
+
void LinkImpl::seal()
{
this->set_model(surf_network_model);
-
+ Resource::seal();
simgrid::s4u::Link::on_creation(*get_iface());
}
+
void LinkImpl::on_bandwidth_change() const
{
s4u::Link::on_bandwidth_change(this->piface_);