1 /* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "simgrid/s4u/Disk.hpp"
7 #include "simgrid/s4u/Engine.hpp"
8 #include "simgrid/s4u/Host.hpp"
9 #include "simgrid/s4u/Io.hpp"
10 #include "src/kernel/resource/DiskImpl.hpp"
14 template class Extendable<s4u::Disk>;
19 xbt::signal<void(Disk&)> Disk::on_creation;
20 xbt::signal<void(Disk const&)> Disk::on_destruction;
21 xbt::signal<void(Disk const&)> Disk::on_state_change;
23 double Disk::get_read_bandwidth() const
25 return this->pimpl_->get_read_bandwidth();
28 double Disk::get_write_bandwidth()
30 return pimpl_->get_write_bandwidth();
33 Host* Disk::get_host()
35 return pimpl_->get_host();
38 const std::unordered_map<std::string, std::string>* Disk::get_properties() const
40 return pimpl_->get_properties();
43 const char* Disk::get_property(const std::string& key) const
45 return this->pimpl_->get_property(key);
48 void Disk::set_property(const std::string& key, const std::string& value)
50 kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
53 IoPtr Disk::io_init(sg_size_t size, Io::OpType type)
55 return IoPtr(new Io(this, size, type));
58 IoPtr Disk::read_async(sg_size_t size)
60 return IoPtr(io_init(size, Io::OpType::READ))->start();
63 sg_size_t Disk::read(sg_size_t size)
65 return IoPtr(io_init(size, Io::OpType::READ))->start()->wait()->get_performed_ioops();
68 IoPtr Disk::write_async(sg_size_t size)
70 return IoPtr(io_init(size, Io::OpType::WRITE)->start());
73 sg_size_t Disk::write(sg_size_t size)
75 return IoPtr(io_init(size, Io::OpType::WRITE))->start()->wait()->get_performed_ioops();
79 } // namespace simgrid