X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b74e91d715c3a4992081917909a1e38df91455cb..9ceefed14c83a0f6ea5f78e3acafd53181dc4fa1:/src/s4u/s4u_Disk.cpp diff --git a/src/s4u/s4u_Disk.cpp b/src/s4u/s4u_Disk.cpp index 3c7334d4a1..5793eb5b0f 100644 --- a/src/s4u/s4u_Disk.cpp +++ b/src/s4u/s4u_Disk.cpp @@ -3,11 +3,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "simgrid/s4u/Disk.hpp" -#include "simgrid/s4u/Engine.hpp" -#include "simgrid/s4u/Host.hpp" -#include "simgrid/s4u/Io.hpp" -#include "simgrid/simix.hpp" +#include +#include +#include + #include "src/kernel/resource/DiskImpl.hpp" namespace simgrid { @@ -20,10 +19,14 @@ xbt::signal Disk::on_creation; xbt::signal Disk::on_destruction; xbt::signal Disk::on_state_change; -Disk* Disk::set_name(const std::string& name) +const std::string& Disk::get_name() const { - name_ = name; - return this; + return pimpl_->get_name(); +} + +const char* Disk::get_cname() const +{ + return pimpl_->get_cname(); } Disk* Disk::set_read_bandwidth(double read_bw) @@ -43,6 +46,12 @@ double Disk::get_read_bandwidth() const return pimpl_->get_read_bandwidth(); } +Disk* Disk::set_readwrite_bandwidth(double bw) +{ + kernel::actor::simcall([this, bw] { pimpl_->set_readwrite_bandwidth(bw); }); + return this; +} + double Disk::get_write_bandwidth() const { return pimpl_->get_write_bandwidth(); @@ -69,41 +78,104 @@ const char* Disk::get_property(const std::string& key) const return pimpl_->get_property(key); } -void Disk::set_property(const std::string& key, const std::string& value) +Disk* Disk::set_property(const std::string& key, const std::string& value) { kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); }); + return this; +} + +Disk* Disk::set_properties(const std::unordered_map& properties) +{ + kernel::actor::simcall([this, properties] { this->pimpl_->set_properties(properties); }); + return this; +} + +Disk* Disk::set_state_profile(kernel::profile::Profile* profile) +{ + xbt_assert(not pimpl_->is_sealed(), "Cannot set a state profile once the Disk is sealed"); + kernel::actor::simcall([this, profile]() { this->pimpl_->set_state_profile(profile); }); + return this; +} + +Disk* Disk::set_read_bandwidth_profile(kernel::profile::Profile* profile) +{ + xbt_assert(not pimpl_->is_sealed(), "Cannot set a bandwidth profile once the Disk is sealed"); + kernel::actor::simcall([this, profile]() { this->pimpl_->set_read_bandwidth_profile(profile); }); + return this; } -IoPtr Disk::io_init(sg_size_t size, Io::OpType type) +Disk* Disk::set_write_bandwidth_profile(kernel::profile::Profile* profile) +{ + xbt_assert(not pimpl_->is_sealed(), "Cannot set a bandwidth profile once the Disk is sealed"); + kernel::actor::simcall([this, profile]() { this->pimpl_->set_write_bandwidth_profile(profile); }); + return this; +} + +IoPtr Disk::io_init(sg_size_t size, Io::OpType type) const { return Io::init()->set_disk(this)->set_size(size)->set_op_type(type); } -IoPtr Disk::read_async(sg_size_t size) +IoPtr Disk::read_async(sg_size_t size) const { return IoPtr(io_init(size, Io::OpType::READ))->vetoable_start(); } -sg_size_t Disk::read(sg_size_t size) +sg_size_t Disk::read(sg_size_t size) const { return IoPtr(io_init(size, Io::OpType::READ))->vetoable_start()->wait()->get_performed_ioops(); } -IoPtr Disk::write_async(sg_size_t size) +sg_size_t Disk::read(sg_size_t size, double priority) const +{ + return IoPtr(io_init(size, Io::OpType::READ)) + ->set_priority(priority) + ->vetoable_start() + ->wait() + ->get_performed_ioops(); +} + +IoPtr Disk::write_async(sg_size_t size) const { return IoPtr(io_init(size, Io::OpType::WRITE)->vetoable_start()); } -sg_size_t Disk::write(sg_size_t size) +sg_size_t Disk::write(sg_size_t size) const { return IoPtr(io_init(size, Io::OpType::WRITE))->vetoable_start()->wait()->get_performed_ioops(); } -void Disk::seal() +sg_size_t Disk::write(sg_size_t size, double priority) const +{ + return IoPtr(io_init(size, Io::OpType::WRITE)) + ->set_priority(priority) + ->vetoable_start() + ->wait() + ->get_performed_ioops(); +} + +Disk* Disk::set_sharing_policy(Disk::Operation op, Disk::SharingPolicy policy, const NonLinearResourceCb& cb) +{ + kernel::actor::simcall([this, op, policy, &cb] { pimpl_->set_sharing_policy(op, policy, cb); }); + return this; +} + +Disk::SharingPolicy Disk::get_sharing_policy(Operation op) const +{ + return this->pimpl_->get_sharing_policy(op); +} + +Disk* Disk::set_factor_cb(const std::function& cb) +{ + kernel::actor::simcall([this, &cb] { pimpl_->set_factor_cb(cb); }); + return this; +} + +Disk* Disk::seal() { kernel::actor::simcall([this]{ pimpl_->seal(); }); - get_host()->add_disk(this); - Disk::on_creation(*this); + Disk::on_creation(*this); // notify the signal + return this; } } // namespace s4u } // namespace simgrid @@ -130,11 +202,11 @@ double sg_disk_write_bandwidth(const_sg_disk_t disk) return disk->get_write_bandwidth(); } -sg_size_t sg_disk_read(sg_disk_t disk, sg_size_t size) +sg_size_t sg_disk_read(const_sg_disk_t disk, sg_size_t size) { return disk->read(size); } -sg_size_t sg_disk_write(sg_disk_t disk, sg_size_t size) +sg_size_t sg_disk_write(const_sg_disk_t disk, sg_size_t size) { return disk->write(size); }