Logo AND Algorithmique Numérique Distribuée

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