Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill the now useless type xbt::string
[simgrid.git] / include / simgrid / s4u / Io.hpp
1 /* Copyright (c) 2017-2022. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef SIMGRID_S4U_IO_HPP
7 #define SIMGRID_S4U_IO_HPP
8
9 #include <simgrid/forward.h>
10 #include <simgrid/s4u/Activity.hpp>
11
12 #include <string>
13
14 namespace simgrid {
15 namespace s4u {
16
17 /** I/O Activity, representing the asynchronous disk access.
18  *
19  * They are generated from Disk::io_init(), Disk::read() Disk::read_async(), Disk::write() and Disk::write_async().
20  */
21
22 class XBT_PUBLIC Io : public Activity_T<Io> {
23 #ifndef DOXYGEN
24   friend kernel::activity::IoImpl;
25   friend kernel::EngineImpl;
26 #endif
27
28   static xbt::signal<void(Io const&)> on_start;
29
30 protected:
31   explicit Io(kernel::activity::IoImplPtr pimpl);
32
33 public:
34   enum class OpType { READ, WRITE };
35
36   static void on_start_cb(const std::function<void(Io const&)>& cb) { on_start.connect(cb); }
37
38   static IoPtr init();
39   Io* start() override;
40   /*! take a vector of s4u::IoPtr and return when one of them is finished.
41    * The return value is the rank of the first finished IoPtr. */
42   static ssize_t wait_any(const std::vector<IoPtr>& ios) { return wait_any_for(ios, -1); }
43   /*! Same as wait_any, but with a timeout. If the timeout occurs, parameter last is returned.*/
44   static ssize_t wait_any_for(const std::vector<IoPtr>& ios, double timeout);
45
46   double get_remaining() const override;
47   sg_size_t get_performed_ioops() const;
48   IoPtr set_disk(const_sg_disk_t disk);
49   IoPtr set_priority(double priority);
50   IoPtr set_size(sg_size_t size);
51   IoPtr set_op_type(OpType type);
52
53   static IoPtr streamto_init(Host* from, Disk* from_disk, Host* to, Disk* to_disk);
54   static IoPtr streamto_async(Host* from, Disk* from_disk, Host* to, Disk* to_disk, uint64_t simulated_size_in_bytes);
55   static void streamto(Host* from, Disk* from_disk, Host* to, Disk* to_disk, uint64_t simulated_size_in_bytes);
56
57   IoPtr set_source(Host* from, Disk* from_disk);
58   IoPtr set_destination(Host* to, Disk* to_disk);
59
60   IoPtr update_priority(double priority);
61
62   bool is_assigned() const override;
63 };
64
65 } // namespace s4u
66 } // namespace simgrid
67
68 #endif /* SIMGRID_S4U_IO_HPP */