const std::unordered_map<std::string, std::string>* get_properties() const;
const char* get_property(const std::string& key) const;
void set_property(const std::string&, const std::string& value);
+ Disk* set_host(Host* host);
Host* get_host() const;
IoPtr io_init(sg_size_t size, s4u::Io::OpType type);
IoPtr write_async(sg_size_t size);
sg_size_t write(sg_size_t size);
+ void seal();
+
#ifndef DOXYGEN
kernel::resource::DiskImpl* get_impl() const { return pimpl_; }
#endif
}
}
+void DiskImpl::seal()
+{
+ lmm::System* maxmin_system = surf_disk_model->get_maxmin_system();
+ this->set_read_constraint(maxmin_system->constraint_new(this, read_bw_))
+ ->set_write_constraint(maxmin_system->constraint_new(this, write_bw_))
+ ->set_model(surf_disk_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_);
+ turn_on();
+}
xbt::signal<void(DiskAction const&, Action::State, Action::State)> DiskAction::on_state_change;
/**********
void turn_on() override;
void turn_off() override;
+ void seal();
void destroy(); // Must be called instead of the destructor
virtual DiskAction* io_start(sg_size_t size, s4u::Io::OpType type) = 0;
virtual DiskAction* read(sg_size_t size) = 0;
return pimpl_->get_write_bandwidth();
}
+Disk* Disk::set_host(Host* host)
+{
+ pimpl_->set_host(host);
+ return this;
+}
+
Host* Disk::get_host() const
{
return pimpl_->get_host();
return IoPtr(io_init(size, Io::OpType::WRITE))->vetoable_start()->wait()->get_performed_ioops();
}
+void Disk::seal()
+{
+ kernel::actor::simcall([this]{ pimpl_->seal(); });
+ get_host()->add_disk(this);
+ Disk::on_creation(*this);
+}
} // namespace s4u
} // namespace simgrid
Disk* Host::create_disk()
{
auto pimpl = surf_disk_model->create_disk();
+ pimpl->set_host(this);
return pimpl->get_iface();
}
simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk)
{
- simgrid::kernel::lmm::System* maxmin_system = surf_disk_model->get_maxmin_system();
simgrid::kernel::resource::DiskImpl* pimpl = surf_disk_model->create_disk();
// This should be done using s4u::Disk methods and passed to the pimpl
pimpl->set_properties(*disk->properties);
delete disk->properties;
}
+ pimpl->get_iface()->set_name(disk->id);
// This should be done in the seal() of a Disk creation
- pimpl->set_read_constraint(maxmin_system->constraint_new(pimpl,disk->read_bw))
- ->set_write_constraint(maxmin_system->constraint_new(pimpl, disk->write_bw))
- ->set_model(surf_disk_model)
- ->set_constraint(maxmin_system->constraint_new(pimpl, std::max(disk->read_bw, disk->write_bw)));
-
- XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", disk->read_bw, disk->write_bw);
- pimpl->turn_on();
-
- // Temporary hack
- pimpl->get_iface()->set_name(disk->id);
+ pimpl->seal();
simgrid::s4u::Disk::on_creation(*pimpl->get_iface());
return pimpl;
}