1 /* Copyright (c) 2017-2021. 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 #ifndef SIMGRID_S4U_IO_HPP
7 #define SIMGRID_S4U_IO_HPP
9 #include <simgrid/forward.h>
10 #include <simgrid/s4u/Activity.hpp>
17 /** I/O Activity, representing the asynchronous disk access.
19 * They are generated from Disk::io_init(), Disk::read() Disk::read_async(), Disk::write() and Disk::write_async().
22 class XBT_PUBLIC Io : public Activity_T<Io> {
24 enum class OpType { READ, WRITE };
27 Storage* storage_ = nullptr;
28 Disk* disk_ = nullptr;
30 OpType type_ = OpType::READ;
36 friend Disk; // Factory of IOs
37 friend Storage; // Factory of IOs
39 ~Io() override = default;
42 static xbt::signal<void(Io const&)> on_start;
43 static xbt::signal<void(Io const&)> on_completion;
48 Io* wait_for(double timeout) override;
49 Io* cancel() override;
51 double get_remaining() const override;
52 sg_size_t get_performed_ioops() const;
53 IoPtr set_disk(sg_disk_t disk);
54 IoPtr set_storage(sg_storage_t storage);
55 IoPtr set_size(sg_size_t size);
56 IoPtr set_op_type(OpType type);
60 } // namespace simgrid
62 #endif /* SIMGRID_S4U_IO_HPP */