-/* 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. */
xbt::signal<void(Disk const&)> Disk::on_destruction;
xbt::signal<void(Disk const&)> Disk::on_state_change;
+Disk* Disk::set_name(const std::string& name)
+{
+ name_ = name;
+ return this;
+}
+
+Disk* Disk::set_read_bandwidth(double read_bw)
+{
+ pimpl_->set_read_bandwidth(read_bw);
+ return this;
+}
+
+Disk* Disk::set_write_bandwidth(double 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_write_bandwidth();
}
+Disk* Disk::set_host(Host* host)
+{
+ pimpl_->set_host(host);
+ return this;
+}
+
Host* Disk::get_host() const
{
return pimpl_->get_host();
IoPtr Disk::io_init(sg_size_t size, Io::OpType type)
{
- return IoPtr(new Io(this, size, type));
+ return Io::init()->set_disk(this)->set_size(size)->set_op_type(type);
}
IoPtr Disk::read_async(sg_size_t size)
{
- return IoPtr(io_init(size, Io::OpType::READ))->start();
+ return IoPtr(io_init(size, Io::OpType::READ))->vetoable_start();
}
sg_size_t Disk::read(sg_size_t size)
{
- return IoPtr(io_init(size, Io::OpType::READ))->start()->wait()->get_performed_ioops();
+ return IoPtr(io_init(size, Io::OpType::READ))->vetoable_start()->wait()->get_performed_ioops();
}
IoPtr Disk::write_async(sg_size_t size)
{
- return IoPtr(io_init(size, Io::OpType::WRITE)->start());
+ return IoPtr(io_init(size, Io::OpType::WRITE)->vetoable_start());
}
sg_size_t Disk::write(sg_size_t size)
{
- return IoPtr(io_init(size, Io::OpType::WRITE))->start()->wait()->get_performed_ioops();
+ return IoPtr(io_init(size, Io::OpType::WRITE))->vetoable_start()->wait()->get_performed_ioops();
}
+void Disk::seal()
+{
+ kernel::actor::simcall([this]{ pimpl_->seal(); });
+ get_host()->add_disk(this);
+ Disk::on_creation(*this);
+}
} // namespace s4u
} // namespace simgrid