Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New function: s4u::Activity::test()
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 24 Aug 2018 13:14:25 +0000 (15:14 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 24 Aug 2018 13:14:30 +0000 (15:14 +0200)
Previously, it was only in some of the subclasses
(also, hide some deprecated symbols from Doxygen)

include/simgrid/s4u/Activity.hpp
include/simgrid/s4u/Comm.hpp
include/simgrid/s4u/Exec.hpp
include/simgrid/s4u/Io.hpp
src/s4u/s4u_Comm.cpp
src/s4u/s4u_Io.cpp

index 8c08594..3a374a4 100644 (file)
@@ -43,8 +43,10 @@ protected:
   virtual ~Activity() = default;
 
 public:
+#ifndef DOXYGEN
   Activity(Activity const&) = delete;
   Activity& operator=(Activity const&) = delete;
+#endif
 
   enum class State { INITED = 0, STARTED, CANCELED, ERRORED, FINISHED };
 
@@ -64,6 +66,8 @@ public:
   virtual Activity* cancel() = 0;
   /** Retrieve the current state of the activity */
   Activity::State get_state() { return state_; }
+  /** Returns whether this activity is completed */
+  virtual bool test() = 0;
 
   /** Get the remaining amount of work that this Activity entails. When it's 0, it's done. */
   virtual double get_remaining();
@@ -82,6 +86,7 @@ public:
   /** Retrieve the user data of the Activity */
   void* get_user_data() { return user_data_; }
 
+#ifndef DOXYGEN
   /** @deprecated See Activity::get_state()*/
   XBT_ATTRIB_DEPRECATED_v323("Please use Activity::get_state()") Activity::State getState() { return state_; }
   /** @deprecated See Activity::get_remaining() */
@@ -98,6 +103,7 @@ public:
   }
   /** @deprecated See Activity::get_user_data() */
   XBT_ATTRIB_DEPRECATED_v323("Please use Activity::get_user_data()") void* getUserData() { return user_data_; }
+#endif
 
 private:
   simgrid::kernel::activity::ActivityImplPtr pimpl_ = nullptr;
index 4eef82f..a057630 100644 (file)
@@ -45,6 +45,7 @@ public:
   Activity* start() override;
   Activity* wait() override;
   Activity* wait(double timeout) override;
+  bool test() override;
 
   /** Start the comm, and ignore its result. It can be completely forgotten after that. */
   Activity* detach();
@@ -72,12 +73,12 @@ public:
   /** Retrieve the size of the received data */
   size_t get_dst_data_size();
 
-  bool test();
   Activity* cancel() override;
 
   /** Retrieve the mailbox on which this comm acts */
   MailboxPtr get_mailbox();
 
+#ifndef DOXYGEN
   /** @deprecated See Comm::set_rate() */
   XBT_ATTRIB_DEPRECATED_v323("Please use Comm::set_rate()") Activity* setRate(double rate) { return set_rate(rate); }
   /** @deprecated See Comm::set_src_data() */
@@ -112,6 +113,7 @@ public:
   }
   /** @deprecated See Comm::get_mailbox() */
   XBT_ATTRIB_DEPRECATED_v323("Please use Comm::get_mailbox()") MailboxPtr getMailbox() { return get_mailbox(); }
+#endif
 
 private:
   double rate_        = -1;
index c50118d..94e64f3 100644 (file)
@@ -35,7 +35,7 @@ public:
   Activity* wait() override;
   Activity* wait(double timeout) override;
   Activity* cancel() override;
-  bool test();
+  bool test() override;
 
   ExecPtr set_priority(double priority);
   ExecPtr set_bound(double bound);
index b47c7e7..2bbdb75 100644 (file)
@@ -37,6 +37,7 @@ public:
   Activity* wait() override;
   Activity* wait(double timeout) override;
   Activity* cancel() override;
+  bool test() override;
 
   double get_remaining() override;
   sg_size_t get_performed_ioops();
index bebc91b..a5d5e5f 100644 (file)
@@ -53,9 +53,8 @@ void Comm::wait_all(std::vector<CommPtr>* comms)
 {
   // TODO: this should be a simcall or something
   // TODO: we are missing a version with timeout
-  for (CommPtr comm : *comms) {
+  for (CommPtr comm : *comms)
     comm->wait();
-  }
 }
 
 Activity* Comm::set_rate(double rate)
index e77c117..c80bd87 100644 (file)
@@ -44,6 +44,21 @@ Activity* Io::wait(double timeout)
   return this;
 }
 
+bool Io::test()
+{
+  xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::FINISHED);
+
+  if (state_ == State::FINISHED)
+    return true;
+
+  if (state_ == State::INITED)
+    this->start();
+
+  THROW_UNIMPLEMENTED;
+
+  return false;
+}
+
 /** @brief Returns the amount of flops that remain to be done */
 double Io::get_remaining()
 {