1 /* Copyright (c) 2019-2020. 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 xbt::Extendable<s4u::Disk>;
18 xbt::signal<void(Disk&)> Disk::on_creation;
19 xbt::signal<void(Disk const&)> Disk::on_destruction;
20 xbt::signal<void(Disk const&)> Disk::on_state_change;
22 double Disk::get_read_bandwidth() const
24 return this->pimpl_->get_read_bandwidth();
27 double Disk::get_write_bandwidth() const
29 return pimpl_->get_write_bandwidth();
32 Host* Disk::get_host() const
34 return pimpl_->get_host();
37 const std::unordered_map<std::string, std::string>* Disk::get_properties() const
39 return pimpl_->get_properties();
42 const char* Disk::get_property(const std::string& key) const
44 return this->pimpl_->get_property(key);
47 void Disk::set_property(const std::string& key, const std::string& value)
49 kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
52 IoPtr Disk::io_init(sg_size_t size, Io::OpType type)
54 return IoPtr(new Io(this, size, type));
57 IoPtr Disk::read_async(sg_size_t size)
59 return IoPtr(io_init(size, Io::OpType::READ))->start();
62 sg_size_t Disk::read(sg_size_t size)
64 return IoPtr(io_init(size, Io::OpType::READ))->start()->wait()->get_performed_ioops();
67 IoPtr Disk::write_async(sg_size_t size)
69 return IoPtr(io_init(size, Io::OpType::WRITE)->start());
72 sg_size_t Disk::write(sg_size_t size)
74 return IoPtr(io_init(size, Io::OpType::WRITE))->start()->wait()->get_performed_ioops();
78 } // namespace simgrid