* Resource *
************/
-DiskImpl::DiskImpl(kernel::resource::Model* model, const std::string& name, kernel::lmm::System* maxminSystem,
- double read_bw, double write_bw)
- : piface_(name, this)
- , read_bw_(read_bw)
- , write_bw_(write_bw)
+DiskImpl* DiskImpl::set_read_bandwidth(double read_bw)
{
- this->set_name(name)->set_model(model)->set_constraint(maxminSystem->constraint_new(this, std::max(read_bw, write_bw)));
- DiskImpl::turn_on();
- XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw_, write_bw_);
- constraint_read_ = maxminSystem->constraint_new(this, read_bw);
- constraint_write_ = maxminSystem->constraint_new(this, write_bw);
+ read_bw_ = read_bw;
+ return this;
+}
+
+DiskImpl* DiskImpl::set_write_bandwidth(double write_bw)
+{
+ write_bw_ = write_bw;
+ return this;
+}
+
+DiskImpl* DiskImpl::set_read_constraint(lmm::Constraint* constraint_read)
+{
+ constraint_read_ = constraint_read;
+ return this;
+}
+
+DiskImpl* DiskImpl::set_write_constraint(lmm::Constraint* constraint_write)
+{
+ constraint_write_ = constraint_write;
+ return this;
}
/** @brief Fire the required callbacks and destroy the object
class DiskImpl : public Resource, public xbt::PropertyHolder {
s4u::Host* host_ = nullptr;
s4u::Disk piface_;
- double read_bw_;
- double write_bw_;
- lmm::Constraint* constraint_write_; /* Constraint for maximum write bandwidth*/
- lmm::Constraint* constraint_read_; /* Constraint for maximum read bandwidth*/
+ double read_bw_ = -1.0;
+ double write_bw_ = 1.0;
+ lmm::Constraint* constraint_write_ = nullptr; /* Constraint for maximum write bandwidth*/
+ lmm::Constraint* constraint_read_ = nullptr; /* Constraint for maximum read bandwidth*/
protected:
~DiskImpl() override = default; // Disallow direct deletion. Call destroy() instead.
public:
- DiskImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double read_bw, double bwrite_bw);
+ DiskImpl(const std::string& name) : piface_(name, this){}
DiskImpl(const DiskImpl&) = delete;
DiskImpl& operator=(const DiskImpl&) = delete;
s4u::Host* get_host() const { return host_; }
void set_host(s4u::Host* host) { host_ = host; }
+ DiskImpl* set_read_bandwidth(double read_bw);
+ DiskImpl* set_write_bandwidth(double write_bw);
double get_read_bandwidth() const { return read_bw_; }
double get_write_bandwidth() const { return write_bw_; }
+ DiskImpl* set_read_constraint(lmm::Constraint* constraint_read);
lmm::Constraint* get_read_constraint() const { return constraint_read_; }
+ DiskImpl* set_write_constraint(lmm::Constraint* constraint_write);
lmm::Constraint* get_write_constraint() const { return constraint_write_; }
/** @brief Check if the Disk is used (if an action currently uses its resources) */
{
XBT_DEBUG("SURF disk create resource\n\t\tid '%s'\n\t\tread_bw '%f'\n", id.c_str(), read_bw);
- return new DiskS19(this, id, get_maxmin_system(), read_bw, write_bw);
+ return new DiskS19(this, id, read_bw, write_bw);
}
double DiskS19Model::next_occurring_event(double now)
* Resource *
************/
-DiskS19::DiskS19(DiskModel* model, const std::string& name, lmm::System* maxminSystem, double read_bw, double write_bw)
- : DiskImpl(model, name, maxminSystem, read_bw, write_bw)
-{
+DiskS19::DiskS19(DiskModel* model, const std::string& name, double read_bw, double write_bw)
+ : DiskImpl(name)
+{
+ lmm::System* maxmin_system = model->get_maxmin_system();
+ this->set_read_bandwidth(read_bw)
+ ->set_write_bandwidth(write_bw)
+ ->set_read_constraint(maxmin_system->constraint_new(this, read_bw))
+ ->set_write_constraint(maxmin_system->constraint_new(this, write_bw))
+ ->set_name(name)
+ ->set_model(model)
+ ->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);
+ DiskImpl::turn_on();
}
DiskAction* DiskS19::io_start(sg_size_t size, s4u::Io::OpType type)
class DiskS19 : public DiskImpl {
public:
- DiskS19(DiskModel* model, const std::string& name, kernel::lmm::System* maxminSystem, double read_bw,
- double write_bw);
+ DiskS19(DiskModel* model, const std::string& name, double read_bw, double write_bw);
DiskAction* io_start(sg_size_t size, s4u::Io::OpType type) override;
DiskAction* read(sg_size_t size) override;
DiskAction* write(sg_size_t size) override;
simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk)
{
+
simgrid::kernel::resource::DiskImpl* d = surf_disk_model->createDisk(disk->id, disk->read_bw, disk->write_bw);
if (disk->properties) {
d->set_properties(*disk->properties);