Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define method test() in Activity (common to Exec and Io).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 7 Feb 2020 14:14:09 +0000 (15:14 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 7 Feb 2020 15:37:44 +0000 (16:37 +0100)
s4u::Comm still uses old-style simcalls (thanks MC) and cannot use it now.

include/simgrid/s4u/Activity.hpp
include/simgrid/s4u/Exec.hpp
include/simgrid/s4u/Io.hpp
src/s4u/s4u_Activity.cpp
src/s4u/s4u_Exec.cpp
src/s4u/s4u_Io.cpp

index e92d768..c38231f 100644 (file)
@@ -90,8 +90,9 @@ public:
   /** Retrieve the current state of the activity */
   Activity::State get_state() const { return state_; }
   void set_state(Activity::State state) { state_ = state; }
-  /** Tests whether the given activity is terminated yet. This is a pure function. */
-  virtual bool test() = 0;
+  /** Tests whether the given activity is terminated yet. */
+  virtual bool test();
+
   virtual const char* get_cname() const       = 0;
   virtual const std::string& get_name() const = 0;
 
index 67792c1..e389291 100644 (file)
@@ -63,8 +63,6 @@ public:
   /*! Same as wait_any, but with a timeout. If the timeout occurs, parameter last is returned.*/
   static int wait_any_for(std::vector<ExecPtr>* execs, double timeout);
 
-  bool test() override;
-
   ExecPtr set_bound(double bound);
   ExecPtr set_priority(double priority);
   XBT_ATTRIB_DEPRECATED_v329("Please use exec_init(...)->wait_for(timeout)") ExecPtr set_timeout(double timeout);
index 2ad47c0..557eddf 100644 (file)
@@ -44,7 +44,6 @@ public:
   Io* wait() override;
   Io* wait_for(double timeout) override;
   Io* cancel() override;
-  bool test() override;
 
   double get_remaining() const override;
   sg_size_t get_performed_ioops() const;
index 3f7404e..1560c50 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "simgrid/s4u/Activity.hpp"
 #include "simgrid/s4u/Engine.hpp"
+#include "src/kernel/activity/ActivityImpl.hpp"
 
 XBT_LOG_EXTERNAL_CATEGORY(s4u);
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_activity, s4u, "S4U activities");
@@ -21,6 +22,26 @@ void Activity::wait_until(double time_limit)
     wait_for(time_limit - now);
 }
 
+bool Activity::test()
+{
+  xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::STARTING ||
+             state_ == State::FINISHED);
+
+  if (state_ == State::FINISHED)
+    return true;
+
+  if (state_ == State::INITED || state_ == State::STARTING)
+    this->vetoable_start();
+
+  if (kernel::actor::simcall([this] { return this->get_impl()->test(); })) {
+    state_ = State::FINISHED;
+    this->release_dependencies();
+    return true;
+  }
+
+  return false;
+}
+
 double Activity::get_remaining() const
 {
   return remains_;
index f443e16..eb3eb3f 100644 (file)
@@ -20,26 +20,6 @@ Exec::Exec()
   pimpl_ = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl());
 }
 
-bool Exec::test()
-{
-  xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::STARTING ||
-             state_ == State::FINISHED);
-
-  if (state_ == State::FINISHED)
-    return true;
-
-  if (state_ == State::INITED || state_ == State::STARTING)
-    this->vetoable_start();
-
-  if (kernel::actor::simcall([this] { return this->get_impl()->test(); })) {
-    state_ = State::FINISHED;
-    this->release_dependencies();
-    return true;
-  }
-
-  return false;
-}
-
 Exec* Exec::wait()
 {
   return this->wait_for(-1);
index ddfaa61..7de8c80 100644 (file)
@@ -69,26 +69,6 @@ Io* Io::wait_for(double timeout)
   return this;
 }
 
-bool Io::test()
-{
-  xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::STARTING ||
-             state_ == State::FINISHED);
-
-  if (state_ == State::FINISHED)
-    return true;
-
-  if (state_ == State::INITED || state_ == State::STARTING)
-    this->vetoable_start();
-
-  if (kernel::actor::simcall([this] { return this->get_impl()->test(); })) {
-    state_ = State::FINISHED;
-    this->release_dependencies();
-    return true;
-  }
-
-  return false;
-}
-
 /** @brief Returns the amount of flops that remain to be done */
 double Io::get_remaining() const
 {