- :cpp:func:`Actor::on_creation <simgrid::s4u::Actor::on_creation_cb>`
:cpp:func:`Actor::on_suspend <simgrid::s4u::Actor::on_suspend_cb>`
+ :cpp:func:`Actor::on_this_suspend <simgrid::s4u::Actor::on_this_suspend_cb>`
:cpp:func:`Actor::on_resume <simgrid::s4u::Actor::on_resume_cb>`
+ :cpp:func:`Actor::on_this_resume <simgrid::s4u::Actor::on_this_resume_cb>`
:cpp:func:`Actor::on_sleep <simgrid::s4u::Actor::on_sleep_cb>`
+ :cpp:func:`Actor::on_this_sleep <simgrid::s4u::Actor::on_this_sleep_cb>`
:cpp:func:`Actor::on_wake_up <simgrid::s4u::Actor::on_wake_up_cb>`
+ :cpp:func:`Actor::on_this_wake_up <simgrid::s4u::Actor::on_this_wake_up_cb>`
:cpp:func:`Actor::on_host_change <simgrid::s4u::Actor::on_host_change_cb>`
+ :cpp:func:`Actor::on_this_host_change <simgrid::s4u::Actor::on_this_host_change_cb>`
:cpp:func:`Actor::on_termination <simgrid::s4u::Actor::on_termination_cb>`
+ :cpp:func:`Actor::on_this_termination <simgrid::s4u::Actor::on_this_termination_cb>`
:cpp:func:`Actor::on_destruction <simgrid::s4u::Actor::on_destruction_cb>`
- :cpp:func:`Comm::on_send <simgrid::s4u::Comm::on_send_cb>`
:cpp:func:`Comm::on_recv <simgrid::s4u::Comm::on_recv_cb>`
.. doxygenfunction:: simgrid::s4u::Actor::on_creation_cb
.. doxygenfunction:: simgrid::s4u::Actor::on_suspend_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_this_suspend_cb
.. doxygenfunction:: simgrid::s4u::Actor::on_host_change_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_this_host_change_cb
.. doxygenfunction:: simgrid::s4u::Actor::on_resume_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_this_resume_cb
.. doxygenfunction:: simgrid::s4u::Actor::on_sleep_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_this_sleep_cb
.. doxygenfunction:: simgrid::s4u::Actor::on_wake_up_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_this_wake_up_cb
.. doxygenfunction:: simgrid::s4u::Actor::on_termination_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_this_termination_cb
.. doxygenfunction:: simgrid::s4u::Actor::on_destruction_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_this_destruction_cb
.. _API_s4u_this_actor:
private:
static xbt::signal<void(Actor&)> on_creation;
static xbt::signal<void(Actor const&)> on_suspend;
+ xbt::signal<void(Actor const&)> on_this_suspend;
static xbt::signal<void(Actor const&)> on_resume;
+ xbt::signal<void(Actor const&)> on_this_resume;
static xbt::signal<void(Actor const&)> on_sleep;
+ xbt::signal<void(Actor const&)> on_this_sleep;
static xbt::signal<void(Actor const&)> on_wake_up;
+ xbt::signal<void(Actor const&)> on_this_wake_up;
static xbt::signal<void(const Actor&, const Host& previous_location)> on_host_change;
+ xbt::signal<void(const Actor&, const Host& previous_location)> on_this_host_change;
static xbt::signal<void(Actor const&)> on_termination;
+ xbt::signal<void(Actor const&)> on_this_termination;
static xbt::signal<void(Actor const&)> on_destruction;
+ xbt::signal<void(Actor const&)> on_this_destruction;
public:
/** Add a callback fired when a new actor has been created **/
static void on_creation_cb(const std::function<void(Actor&)>& cb) { on_creation.connect(cb); }
- /** Add a callback fired when an actor has been suspended**/
+ /** Add a callback fired when any actor is suspended**/
static void on_suspend_cb(const std::function<void(Actor const&)>& cb) { on_suspend.connect(cb); }
- /** Add a callback fired when an actor has been resumed **/
+ /** Add a callback fired when this specific actor is suspended**/
+ void on_this_suspend_cb(const std::function<void(Actor const&)>& cb) { on_this_suspend.connect(cb); }
+ /** Add a callback fired when any actor is resumed **/
static void on_resume_cb(const std::function<void(Actor const&)>& cb) { on_resume.connect(cb); }
- /** Add a callback fired when an actor starts sleeping **/
+ /** Add a callback fired when any actor is resumed **/
+ void on_this_resume_cb(const std::function<void(Actor const&)>& cb) { on_this_resume.connect(cb); }
+ /** Add a callback fired when any actor starts sleeping **/
static void on_sleep_cb(const std::function<void(Actor const&)>& cb) { on_sleep.connect(cb); }
- /** Add a callback fired when an actor wakes up from a sleep **/
+ /** Add a callback fired when this specific actor starts sleeping **/
+ void on_this_sleep_cb(const std::function<void(Actor const&)>& cb) { on_this_sleep.connect(cb); }
+ /** Add a callback fired when any actor wakes up from a sleep **/
static void on_wake_up_cb(const std::function<void(Actor const&)>& cb) { on_wake_up.connect(cb); }
- /** Add a callback fired when an actor is has been migrated to another host **/
+ /** Add a callback fired when this specific actor wakes up from a sleep **/
+ void on_this_wake_up_cb(const std::function<void(Actor const&)>& cb) { on_this_wake_up.connect(cb); }
+ /** Add a callback fired when any actor is has been migrated to another host **/
static void on_host_change_cb(const std::function<void(const Actor&, const Host& previous_location)>& cb)
{
on_host_change.connect(cb);
}
+ /** Add a callback fired when this specific actor is has been migrated to another host **/
+ void on_this_host_change_cb(const std::function<void(const Actor&, const Host& previous_location)>& cb)
+ {
+ on_this_host_change.connect(cb);
+ }
- /** Add a callback fired when an actor terminates its code.
+ /** Add a callback fired when any actor terminates its code.
* @beginrst
* The actor may continue to exist if it is still referenced in the simulation, but it's not active anymore.
* If you want to free extra data when the actor's destructor is called, use :cpp:func:`Actor::on_destruction_cb`.
* @endrst
*/
static void on_termination_cb(const std::function<void(Actor const&)>& cb) { on_termination.connect(cb); }
+ /** Add a callback fired when this specific actor terminates its code.
+ * @beginrst
+ * The actor may continue to exist if it is still referenced in the simulation, but it's not active anymore.
+ * If you want to free extra data when the actor's destructor is called, use :cpp:func:`Actor::on_this_destruction_cb`.
+ * @endrst
+ */
+ void on_this_termination_cb(const std::function<void(Actor const&)>& cb) { on_this_termination.connect(cb); }
/** Add a callback fired when an actor is about to disappear (its destructor was called).
- * This signal is fired for any destructed actor, which is mostly useful when designing plugins and extensions.
- * If you want to react to the end of the actor's code, use Actor::on_termination instead.
- * If you want to register to the termination of a given actor, use this_actor::on_exit() instead.*/
+ * This signal is fired for any destructed actor, which is mostly useful when designing plugins and extensions. */
static void on_destruction_cb(const std::function<void(Actor const&)>& cb) { on_destruction.connect(cb); }
+ /** Add a callback fired when this specific actor is about to disappear (its destructor was called). */
+ void on_this_destruction_cb(const std::function<void(Actor const&)>& cb) { on_this_destruction.connect(cb); }
/** Create an actor from a @c std::function<void()>.
* If the actor is restarted, it gets a fresh copy of the function.
});
s4u::Actor::on_host_change(*this, *previous_location);
+ s4u::Actor::on_this_host_change(*this, *previous_location);
}
s4u::Host* Actor::get_host() const
kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
kernel::actor::ActorImpl* target = pimpl_;
s4u::Actor::on_suspend(*this);
+ s4u::Actor::on_this_suspend(*this);
kernel::actor::simcall_blocking([issuer, target]() {
target->suspend();
if (target != issuer) {
{
kernel::actor::simcall_answered([this] { pimpl_->resume(); });
s4u::Actor::on_resume(*this);
+ s4u::Actor::on_this_resume(*this);
}
bool Actor::is_suspended() const
kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
Actor::on_sleep(*issuer->get_ciface());
+ issuer->get_ciface()->on_this_sleep(*issuer->get_ciface());
kernel::actor::simcall_blocking([issuer, duration]() {
if (MC_is_active() || MC_record_replay_is_active()) {
});
Actor::on_wake_up(*issuer->get_ciface());
+ issuer->get_ciface()->on_this_wake_up(*issuer->get_ciface());
}
void yield()
{
kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
s4u::Actor::on_suspend(*self->get_ciface());
+ self->get_ciface()->on_this_suspend(*self->get_ciface());
kernel::actor::simcall_blocking([self] { self->suspend(); });
}