Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce code duplication.
[simgrid.git] / src / kernel / activity / IoImpl.hpp
1 /* Copyright (c) 2007-2022. 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 <simgrid/s4u/Io.hpp>
11
12 namespace simgrid::kernel::activity {
13
14 class XBT_PUBLIC IoImpl : public ActivityImpl_T<IoImpl> {
15   resource::DiskImpl* disk_           = nullptr;
16   double sharing_penalty_             = 1.0;
17   sg_size_t size_                     = 0;
18   s4u::Io::OpType type_               = s4u::Io::OpType::READ;
19   sg_size_t performed_ioops_          = 0;
20   resource::Action* timeout_detector_ = nullptr;
21
22 public:
23   IoImpl();
24
25   IoImpl& set_sharing_penalty(double sharing_penalty);
26   IoImpl& set_timeout(double timeout) override;
27   IoImpl& set_size(sg_size_t size);
28   IoImpl& set_type(s4u::Io::OpType type);
29   IoImpl& set_disk(resource::DiskImpl* disk);
30
31   IoImpl& update_sharing_penalty(double sharing_penalty);
32
33   sg_size_t get_performed_ioops() const { return performed_ioops_; }
34   resource::DiskImpl* get_disk() const { return disk_; }
35
36   IoImpl* start();
37   void post() override;
38   void set_exception(actor::ActorImpl* issuer) override;
39   void finish() override;
40 };
41 } // namespace simgrid::kernel::activity
42
43 #endif