From 206d815a5fa8cea6ab00e40b1736d2a4bf2c50b7 Mon Sep 17 00:00:00 2001 From: Fred Suter Date: Wed, 31 May 2023 16:21:37 -0400 Subject: [PATCH] add on_this_[suspend,resume] signals to Activities --- docs/source/Plugins.rst | 6 ++++++ include/simgrid/s4u/Activity.hpp | 8 +++++++- include/simgrid/s4u/Comm.hpp | 2 ++ include/simgrid/s4u/Exec.hpp | 2 ++ include/simgrid/s4u/Io.hpp | 2 ++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/source/Plugins.rst b/docs/source/Plugins.rst index 0a9669fdb1..b4e5b84cec 100644 --- a/docs/source/Plugins.rst +++ b/docs/source/Plugins.rst @@ -139,21 +139,27 @@ Partial list of existing signals in s4u: :cpp:func:`Comm::on_completion ` :cpp:func:`Comm::on_this_completion ` :cpp:func:`Comm::on_suspend ` + :cpp:func:`Comm::on_this_suspend ` :cpp:func:`Comm::on_resume ` + :cpp:func:`Comm::on_this_resume ` :cpp:func:`Comm::on_veto ` - :cpp:func:`Exec::on_start ` :cpp:func:`Exec::on_this_start ` :cpp:func:`Exec::on_completion ` :cpp:func:`Exec::on_this_completion ` :cpp:func:`Exec::on_suspend ` + :cpp:func:`Exec::on_this_suspend ` :cpp:func:`Exec::on_resume ` + :cpp:func:`Exec::on_this_resume ` :cpp:func:`Exec::on_veto ` - :cpp:func:`Io::on_start ` :cpp:func:`Io::on_this_start ` :cpp:func:`Io::on_completion ` :cpp:func:`Io::on_this_completion ` :cpp:func:`Io::on_suspend ` + :cpp:func:`Io::on_this_suspend ` :cpp:func:`Io::on_resume ` + :cpp:func:`Io::on_this_resume ` :cpp:func:`Io::on_veto ` Existing Plugins diff --git a/include/simgrid/s4u/Activity.hpp b/include/simgrid/s4u/Activity.hpp index 1f8a7ca747..506926b511 100644 --- a/include/simgrid/s4u/Activity.hpp +++ b/include/simgrid/s4u/Activity.hpp @@ -108,7 +108,9 @@ protected: virtual void fire_on_this_completion() const = 0; virtual void fire_on_veto() const = 0; virtual void fire_on_suspend() const = 0; + virtual void fire_on_this_suspend() const = 0; virtual void fire_on_resume() const = 0; + virtual void fire_on_this_resume() const = 0; public: XBT_ATTRIB_DEPRECATED_v334("All start() are vetoable now. Please use start() ") void vetoable_start() @@ -238,19 +240,23 @@ protected: xbt::signal on_this_completion; inline static xbt::signal on_veto; inline static xbt::signal on_suspend; + xbt::signal on_this_suspend; inline static xbt::signal on_resume; + xbt::signal on_this_resume; public: /*! Add a callback fired when the activity completes (either normally, cancelled or failed) */ static void on_completion_cb(const std::function& cb) { on_completion.connect(cb); } - static void on_this_completion_cb(const std::function& cb) { on_this_completion.connect(cb); } + void on_this_completion_cb(const std::function& cb) { on_this_completion.connect(cb); } /*! Add a callback fired each time that the activity fails to start because of a veto (e.g., unsolved dependency or no * resource assigned) */ static void on_veto_cb(const std::function& cb) { on_veto.connect(cb); } /*! Add a callback fired when the activity is suspended */ static void on_suspend_cb(const std::function& cb) { on_suspend.connect(cb); } + void on_this_suspend_cb(const std::function& cb) { on_this_suspend.connect(cb); } /*! Add a callback fired when the activity is resumed after being suspended */ static void on_resume_cb(const std::function& cb) { on_resume.connect(cb); } + void on_this_resume_cb(const std::function& cb) { on_this_resume.connect(cb); } XBT_ATTRIB_DEPRECATED_v337("Please use on_suspend_cb() instead") static void on_suspended_cb( const std::function& cb) { on_suspend.connect(cb); } diff --git a/include/simgrid/s4u/Comm.hpp b/include/simgrid/s4u/Comm.hpp index 0226ec6108..2987d1f83a 100644 --- a/include/simgrid/s4u/Comm.hpp +++ b/include/simgrid/s4u/Comm.hpp @@ -57,7 +57,9 @@ protected: } void fire_on_veto() const override { on_veto(const_cast(*this)); } void fire_on_suspend() const override { on_suspend(*this); } + void fire_on_this_suspend() const override { on_this_suspend(*this); } void fire_on_resume() const override { on_resume(*this); } + void fire_on_this_resume() const override { on_this_resume(*this); } public: static void on_send_cb(const std::function& cb) { on_send.connect(cb); } diff --git a/include/simgrid/s4u/Exec.hpp b/include/simgrid/s4u/Exec.hpp index b544f09296..63da3090bc 100644 --- a/include/simgrid/s4u/Exec.hpp +++ b/include/simgrid/s4u/Exec.hpp @@ -48,7 +48,9 @@ protected: void fire_on_this_completion() const override { on_this_completion(*this); } void fire_on_veto() const override { on_veto(const_cast(*this)); } void fire_on_suspend() const override { on_suspend(*this); } + void fire_on_this_suspend() const override { on_this_suspend(*this); } void fire_on_resume() const override { on_resume(*this); } + void fire_on_this_resume() const override { on_this_resume(*this); } public: #ifndef DOXYGEN diff --git a/include/simgrid/s4u/Io.hpp b/include/simgrid/s4u/Io.hpp index a773d0c4ab..f39fa1911d 100644 --- a/include/simgrid/s4u/Io.hpp +++ b/include/simgrid/s4u/Io.hpp @@ -34,7 +34,9 @@ protected: void fire_on_this_completion() const override { on_this_completion(*this); } void fire_on_veto() const override { on_veto(const_cast(*this)); } void fire_on_suspend() const override { on_suspend(*this); } + void fire_on_this_suspend() const override { on_this_suspend(*this); } void fire_on_resume() const override { on_resume(*this); } + void fire_on_this_resume() const override { on_this_resume(*this); } public: enum class OpType { READ, WRITE }; -- 2.20.1