Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
6052171851016b7ab66bf34f81bb4f743eca0963
[simgrid.git] / include / simgrid / s4u / Io.hpp
1 /* Copyright (c) 2017-2018. 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
14 namespace simgrid {
15 namespace s4u {
16
17 class XBT_PUBLIC Io : public Activity {
18   explicit Io(sg_size_t size) : Activity(), size_(size) {}
19 public:
20   friend XBT_PUBLIC void intrusive_ptr_release(simgrid::s4u::Io* i);
21   friend XBT_PUBLIC void intrusive_ptr_add_ref(simgrid::s4u::Io* i);
22   friend Storage; // Factory of IOs
23
24   enum class OpType { READ, WRITE };
25   ~Io() = default;
26
27   Activity* start() override;
28   Activity* wait() override;
29   Activity* wait(double timeout) override;
30   Activity* cancel() override;
31
32   double get_remaining() override;
33   sg_size_t get_performed_ioops();
34   IoPtr set_io_type(OpType type);
35
36 private:
37   sg_size_t size_       = 0;
38   sg_storage_t storage_ = nullptr;
39   std::string name_     = "";
40   OpType type_          = OpType::READ;
41   std::atomic_int_fast32_t refcount_{0};
42 }; // class
43 }
44 }; // Namespace simgrid::s4u
45
46 #endif /* SIMGRID_S4U_IO_HPP */