Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into depencencies
[simgrid.git] / src / kernel / activity / IoImpl.hpp
1 /* Copyright (c) 2007-2020. 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_KERNEL_ACTIVITY_IO_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_IO_HPP
8
9 #include "src/kernel/activity/ActivityImpl.hpp"
10 #include "surf/surf.hpp"
11 #include <simgrid/s4u/Io.hpp>
12
13 namespace simgrid {
14 namespace kernel {
15 namespace activity {
16
17 class XBT_PUBLIC IoImpl : public ActivityImpl_T<IoImpl> {
18   resource::StorageImpl* storage_ = nullptr;
19   resource::DiskImpl* disk_       = nullptr;
20   sg_size_t size_                 = 0;
21   s4u::Io::OpType type_           = s4u::Io::OpType::READ;
22   sg_size_t performed_ioops_      = 0;
23   resource::Action* timeout_detector_ = nullptr;
24
25 public:
26   IoImpl& set_size(sg_size_t size);
27   IoImpl& set_type(s4u::Io::OpType type);
28   IoImpl& set_storage(resource::StorageImpl* storage);
29   IoImpl& set_disk(resource::DiskImpl* disk);
30
31   void set_timeout_detector(resource::Action* action)
32   {
33     timeout_detector_ = action;
34     timeout_detector_->set_activity(this);
35   }
36
37   sg_size_t get_performed_ioops() { return performed_ioops_; }
38   resource::DiskImpl* get_disk() { return disk_; }
39   resource::StorageImpl* get_storage() { return storage_; }
40
41   IoImpl* start();
42   void post() override;
43   void finish() override;
44
45   static xbt::signal<void(IoImpl const&)> on_start;
46   static xbt::signal<void(IoImpl const&)> on_completion;
47 };
48 } // namespace activity
49 } // namespace kernel
50 } // namespace simgrid
51
52 #endif