Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove features marked with DEPRECATED_v324.
[simgrid.git] / include / simgrid / s4u / Io.hpp
1 /* Copyright (c) 2017-2019. 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 <atomic>
13 #include <string>
14
15 namespace simgrid {
16 namespace s4u {
17
18 /** I/O Activity, representing the asynchronous disk access.
19  *
20  * They are generated from Storage::io_init() or Storage::read() and Storage::write().
21  */
22
23 class XBT_PUBLIC Io : public Activity {
24 public:
25   enum class OpType { READ, WRITE };
26
27 private:
28   Storage* storage_ = nullptr;
29   sg_size_t size_   = 0;
30   OpType type_      = OpType::READ;
31   std::string name_ = "";
32   std::atomic_int_fast32_t refcount_{0};
33
34   explicit Io(sg_storage_t storage, sg_size_t size, OpType type);
35
36 public:
37 #ifndef DOXYGEN
38   friend XBT_PUBLIC void intrusive_ptr_release(simgrid::s4u::Io* i);
39   friend XBT_PUBLIC void intrusive_ptr_add_ref(simgrid::s4u::Io* i);
40   friend Storage; // Factory of IOs
41 #endif
42
43   ~Io() = default;
44
45   Io* start() override;
46   Io* wait() override;
47   Io* wait_for(double timeout) override;
48   Io* cancel() override;
49   bool test() override;
50
51   double get_remaining() override;
52   sg_size_t get_performed_ioops();
53 };
54
55 } // namespace s4u
56 } // namespace simgrid
57
58 #endif /* SIMGRID_S4U_IO_HPP */