Logo AND Algorithmique Numérique Distribuée

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