Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid into CRTP
[simgrid.git] / src / kernel / activity / ExecImpl.hpp
1 /* Copyright (c) 2007-2019. 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 SIMIX_SYNCHRO_EXEC_HPP
7 #define SIMIX_SYNCHRO_EXEC_HPP
8
9 #include "src/kernel/activity/ActivityImpl.hpp"
10 #include "src/kernel/context/Context.hpp"
11 #include "surf/surf.hpp"
12
13 namespace simgrid {
14 namespace kernel {
15 namespace activity {
16
17 class XBT_PUBLIC ExecImpl : public ActivityImpl {
18   resource::Action* timeout_detector_ = nullptr;
19   double priority_                    = 1.0;
20   double bound_                       = 0.0;
21   std::vector<s4u::Host*> hosts_;
22   std::vector<double> flops_amounts_;
23   std::vector<double> bytes_amounts_;
24   ~ExecImpl();
25
26 public:
27   ExecImpl& set_name(const std::string& name);
28   ExecImpl& set_tracing_category(const std::string& category);
29   ExecImpl& set_timeout(double timeout);
30   ExecImpl& set_bound(double bound);
31   ExecImpl& set_priority(double priority);
32
33   ExecImpl& set_flops_amount(double flop_amount);
34   ExecImpl& set_host(s4u::Host* host);
35   s4u::Host* get_host() const { return hosts_.front(); }
36
37   ExecImpl& set_flops_amounts(const std::vector<double>& flops_amounts);
38   ExecImpl& set_bytes_amounts(const std::vector<double>& bytes_amounts);
39   ExecImpl& set_hosts(const std::vector<s4u::Host*>& hosts);
40
41   unsigned int get_host_number() const { return hosts_.size(); }
42   double get_remaining() const;
43   double get_seq_remaining_ratio();
44   double get_par_remaining_ratio();
45   virtual ActivityImpl* migrate(s4u::Host* to);
46
47   ExecImpl* start();
48   void cancel();
49   void post() override;
50   void finish() override;
51
52   static xbt::signal<void(ExecImpl&)> on_creation;
53   static xbt::signal<void(ExecImpl const&)> on_completion;
54   static xbt::signal<void(ExecImpl const&, s4u::Host*)> on_migration;
55 };
56 } // namespace activity
57 } // namespace kernel
58 } // namespace simgrid
59 #endif