Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
43a0031d57ff00c1a2f18039306d61887d01baac
[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 #include <simgrid/s4u/forward.hpp>
12
13 #include <atomic>
14
15 namespace simgrid {
16 namespace s4u {
17
18 class XBT_PUBLIC Exec : public Activity {
19   Exec() : Activity() {}
20 public:
21   friend XBT_PUBLIC void intrusive_ptr_release(simgrid::s4u::Exec * e);
22   friend XBT_PUBLIC void intrusive_ptr_add_ref(simgrid::s4u::Exec * e);
23   friend XBT_PUBLIC ExecPtr this_actor::exec_init(double flops_amount);
24
25   ~Exec() = default;
26
27   Activity* start() override;
28   Activity* wait() override;
29   Activity* wait(double timeout) override;
30   bool test();
31
32   ExecPtr setPriority(double priority);
33   ExecPtr setBound(double bound);
34   ExecPtr setHost(Host * host);
35   Host* getHost() { return host_; }
36
37   double getRemains() override;
38   double getRemainingRatio();
39
40 private:
41   Host* host_          = nullptr;
42   double flops_amount_ = 0.0;
43   double priority_     = 1.0;
44   double bound_        = 0.0;
45   std::atomic_int_fast32_t refcount_{0};
46 }; // class
47 }
48 }; // Namespace simgrid::s4u
49
50 #endif /* SIMGRID_S4U_EXEC_HPP */