Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9616bfe2c595c377a973f92db48a873ba8390a50
[simgrid.git] / include / simgrid / s4u / Exec.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_EXEC_HPP
7 #define SIMGRID_S4U_EXEC_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 Exec : public Activity {
18   Exec() : Activity() {}
19 public:
20   friend XBT_PUBLIC void intrusive_ptr_release(simgrid::s4u::Exec * e);
21   friend XBT_PUBLIC void intrusive_ptr_add_ref(simgrid::s4u::Exec * e);
22   friend XBT_PUBLIC ExecPtr this_actor::exec_init(double flops_amount);
23
24   ~Exec() = default;
25
26   Activity* start() override;
27   Activity* wait() override;
28   Activity* wait(double timeout) override;
29   bool test();
30
31   ExecPtr set_priority(double priority);
32   ExecPtr set_bound(double bound);
33   ExecPtr set_host(Host* host);
34   ExecPtr set_name(std::string name);
35   ExecPtr set_tracing_category(std::string category);
36   Host* get_host();
37
38   double get_remaining() override;
39   double get_remaining_ratio();
40
41   //////////////// Deprecated functions
42   /** @deprecated See Exec::set_priority() */
43   XBT_ATTRIB_DEPRECATED_v323("Please use Exec::set_priority()") ExecPtr setPriority(double priority)
44   {
45     return set_priority(priority);
46   }
47   /** @deprecated See Exec::set_bound() */
48   XBT_ATTRIB_DEPRECATED_v323("Please use Exec::set_bound()") ExecPtr setBound(double bound) { return set_bound(bound); }
49   /** @deprecated See Exec::set_host() */
50   XBT_ATTRIB_DEPRECATED_v323("Please use Exec::set_host()") ExecPtr setHost(Host* host) { return set_host(host); }
51   /** @deprecated See Exec::get_host() */
52   XBT_ATTRIB_DEPRECATED_v323("Please use Exec::get_host()") Host* getHost() { return get_host(); }
53   /** @deprecated See Exec::get_remaining_ratio() */
54   XBT_ATTRIB_DEPRECATED_v323("Please use Exec::get_remaining_ratio()") double getRemainingRatio()
55   {
56     return get_remaining_ratio();
57   }
58
59 private:
60   Host* host_                   = nullptr;
61   double flops_amount_          = 0.0;
62   double priority_              = 1.0;
63   double bound_                 = 0.0;
64   std::string name_             = "";
65   std::string tracing_category_ = "";
66   std::atomic_int_fast32_t refcount_{0};
67 }; // class
68 }
69 }; // Namespace simgrid::s4u
70
71 #endif /* SIMGRID_S4U_EXEC_HPP */