Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add on_this_completion signal to Activities
[simgrid.git] / include / simgrid / s4u / Io.hpp
index a2babc9..a773d0c 100644 (file)
@@ -11,8 +11,7 @@
 
 #include <string>
 
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
 
 /** I/O Activity, representing the asynchronous disk access.
  *
@@ -25,17 +24,23 @@ class XBT_PUBLIC Io : public Activity_T<Io> {
   friend kernel::EngineImpl;
 #endif
 
-  static xbt::signal<void(Io const&)> on_start;
+  inline static xbt::signal<void(Io const&)> on_start;
+  xbt::signal<void(Io const&)> on_this_start;
 
 protected:
   explicit Io(kernel::activity::IoImplPtr pimpl);
   Io* do_start() override;
+  void fire_on_completion() const override { on_completion(*this); }
+  void fire_on_this_completion() const override { on_this_completion(*this); }
+  void fire_on_veto() const override { on_veto(const_cast<Io&>(*this)); }
+  void fire_on_suspend() const override { on_suspend(*this); }
+  void fire_on_resume() const override { on_resume(*this); }
 
 public:
   enum class OpType { READ, WRITE };
 
   static void on_start_cb(const std::function<void(Io const&)>& cb) { on_start.connect(cb); }
-  void fire_this_completion() const override{ on_completion(*this); }
+  void on_this_start_cb(const std::function<void(Io const&)>& cb) { on_this_start.connect(cb); }
 
   static IoPtr init();
   /*! take a vector of s4u::IoPtr and return when one of them is finished.
@@ -65,7 +70,6 @@ public:
   bool is_assigned() const override;
 };
 
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
 
 #endif /* SIMGRID_S4U_IO_HPP */