X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a9e1dca8492517a1d0ba1fe55331d128d42c255a..fa87b694ef63aa4f3193029f4705cc3d96492f04:/src/s4u/s4u_Disk.cpp diff --git a/src/s4u/s4u_Disk.cpp b/src/s4u/s4u_Disk.cpp index 100dc6e8cf..f8f10f81f2 100644 --- a/src/s4u/s4u_Disk.cpp +++ b/src/s4u/s4u_Disk.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2019-2021. The SimGrid Team. All rights reserved. */ /* 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. */ @@ -20,9 +20,27 @@ xbt::signal Disk::on_creation; xbt::signal Disk::on_destruction; xbt::signal Disk::on_state_change; +Disk* Disk::set_name(const std::string& name) +{ + name_ = name; + return this; +} + +Disk* Disk::set_read_bandwidth(double read_bw) +{ + kernel::actor::simcall([this, read_bw] { pimpl_->set_read_bandwidth(read_bw); }); + return this; +} + +Disk* Disk::set_write_bandwidth(double write_bw) +{ + kernel::actor::simcall([this, write_bw] { pimpl_->set_write_bandwidth(write_bw); }); + return this; +} + double Disk::get_read_bandwidth() const { - return this->pimpl_->get_read_bandwidth(); + return pimpl_->get_read_bandwidth(); } double Disk::get_write_bandwidth() const @@ -30,6 +48,12 @@ double Disk::get_write_bandwidth() const 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(); @@ -42,45 +66,58 @@ const std::unordered_map* Disk::get_properties() const const char* Disk::get_property(const std::string& key) const { - return this->pimpl_->get_property(key); + 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; } -IoPtr Disk::io_init(sg_size_t size, Io::OpType type) +Disk* Disk::set_properties(const std::unordered_map& properties) { - return IoPtr(new Io(this, size, type)); + kernel::actor::simcall([this, properties] { this->pimpl_->set_properties(properties); }); + return this; } -IoPtr Disk::read_async(sg_size_t size) +IoPtr Disk::io_init(sg_size_t size, Io::OpType type) const { - return IoPtr(io_init(size, Io::OpType::READ))->start(); + return Io::init()->set_disk(this)->set_size(size)->set_op_type(type); } -sg_size_t Disk::read(sg_size_t size) +IoPtr Disk::read_async(sg_size_t size) const { - return IoPtr(io_init(size, Io::OpType::READ))->start()->wait()->get_performed_ioops(); + return IoPtr(io_init(size, Io::OpType::READ))->vetoable_start(); } -IoPtr Disk::write_async(sg_size_t size) +sg_size_t Disk::read(sg_size_t size) const { - return IoPtr(io_init(size, Io::OpType::WRITE)->start()); + return IoPtr(io_init(size, Io::OpType::READ))->vetoable_start()->wait()->get_performed_ioops(); } -sg_size_t Disk::write(sg_size_t size) +IoPtr Disk::write_async(sg_size_t size) const { - return IoPtr(io_init(size, Io::OpType::WRITE))->start()->wait()->get_performed_ioops(); + return IoPtr(io_init(size, Io::OpType::WRITE)->vetoable_start()); } +sg_size_t Disk::write(sg_size_t size) const +{ + return IoPtr(io_init(size, Io::OpType::WRITE))->vetoable_start()->wait()->get_performed_ioops(); +} + +Disk* Disk::seal() +{ + kernel::actor::simcall([this]{ pimpl_->seal(); }); + Disk::on_creation(*this); + return this; +} } // namespace s4u } // namespace simgrid /* **************************** Public C interface *************************** */ -const char* sg_disk_name(const_sg_disk_t disk) +const char* sg_disk_get_name(const_sg_disk_t disk) { return disk->get_cname(); } @@ -100,11 +137,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); } @@ -118,13 +155,3 @@ void sg_disk_set_data(sg_disk_t disk, void* data) { disk->set_data(data); } - -void* sg_disk_data(const_sg_disk_t disk) // XBT_ATTRIB_DEPRECATED_v330 -{ - return sg_disk_get_data(disk); -} - -void sg_disk_data_set(sg_disk_t disk, void* data) // XBT_ATTRIB_DEPRECATED_v330 -{ - sg_disk_set_data(disk, data); -}