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 Host* Disk::get_host()
25 return pimpl_->get_host();
28 const std::unordered_map<std::string, std::string>* Disk::get_properties() const
30 return pimpl_->get_properties();
33 const char* Disk::get_property(const std::string& key) const
35 return this->pimpl_->get_property(key);
38 void Disk::set_property(const std::string& key, const std::string& value)
40 kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
43 IoPtr Disk::io_init(sg_size_t size, Io::OpType type)
45 return IoPtr(new Io(this, size, type));
48 IoPtr Disk::read_async(sg_size_t size)
50 return IoPtr(io_init(size, Io::OpType::READ))->start();
53 sg_size_t Disk::read(sg_size_t size)
55 return IoPtr(io_init(size, Io::OpType::READ))->start()->wait()->get_performed_ioops();
58 IoPtr Disk::write_async(sg_size_t size)
61 return IoPtr(io_init(size, Io::OpType::WRITE)->start());
64 sg_size_t Disk::write(sg_size_t size)
66 return IoPtr(io_init(size, Io::OpType::WRITE))->start()->wait()->get_performed_ioops();
70 } // namespace simgrid