Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more chaining for CPUs too
[simgrid.git] / include / simgrid / s4u / Exec.hpp
index d2a6a12..0ae3e32 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,7 +16,7 @@ namespace s4u {
 
 /** Computation Activity, representing the asynchronous executions.
  *
- * @rst
+ * @beginrst
  * Most of them are created with :cpp:func:`simgrid::s4u::this_actor::exec_init()` or
  * :cpp:func:`simgrid::s4u::Host::execute()`, and represent a classical (sequential) execution. This can be used to
  * simulate some computation occurring in another thread when the calling actor is not blocked during the execution.
@@ -30,25 +30,29 @@ namespace s4u {
  * @endrst
  */
 class XBT_PUBLIC Exec : public Activity_T<Exec> {
+  friend kernel::activity::ExecImpl;
   double priority_              = 1.0;
   double bound_                 = 0.0;
-  double timeout_               = 0.0;
+  double timeout_               = -1.0; // Infinite timeout by default
   std::vector<double> flops_amounts_;
   std::vector<double> bytes_amounts_;
   std::vector<Host*> hosts_;
   bool parallel_ = false;
+  double start_time_ = -1.0;
+  double finish_time_ = -1.0;
+
+protected:
+  explicit Exec(kernel::activity::ExecImplPtr pimpl);
 
 public:
-  Exec();
-  ~Exec() override = default;
 #ifndef DOXYGEN
   Exec(Exec const&) = delete;
   Exec& operator=(Exec const&) = delete;
-
 #endif
   static xbt::signal<void(Exec const&)> on_start;
   static xbt::signal<void(Exec const&)> on_completion;
 
+  static ExecPtr init();
   Exec* start() override;
   /** @brief On sequential executions, returns the amount of flops that remain to be done; This cannot be used on
    * parallel executions. */
@@ -76,10 +80,12 @@ public:
   Exec* cancel() override;
   Host* get_host() const;
   unsigned int get_host_number() const;
-  double get_start_time() const;
-  double get_finish_time() const;
+  double get_start_time() const { return start_time_; }
+  double get_finish_time() const { return finish_time_; }
+  void set_finish_time(double finish_time) { finish_time_ = finish_time; }
   double get_cost() const;
   bool is_parallel() const { return parallel_; }
+  bool is_assigned() const override { return not hosts_.empty(); }
 };
 
 } // namespace s4u