:cpp:func:`Host::on_this_state_change <simgrid::s4u::Host::on_this_state_change_cb>`
:cpp:func:`Host::on_speed_change <simgrid::s4u::Host::on_speed_change_cb>`
:cpp:func:`Host::on_this_speed_change <simgrid::s4u::Host::on_this_speed_change_cb>`
+ :cpp:func:`Host::on_exec_state_change <simgrid::s4u::Host::on_exec_state_change_cb>`
- :cpp:func:`Io::on_start <simgrid::s4u::Io::on_start_cb>`
:cpp:func:`Io::on_completion <simgrid::s4u::Io::on_completion_cb>`
- :cpp:func:`Link::on_creation <simgrid::s4u::Link::on_creation_cb>`
:cpp:func:`Link::on_destruction <simgrid::s4u::Link::on_destruction_cb>`
+ :cpp:func:`Link::on_this_destruction <simgrid::s4u::Link::on_this_destruction_cb>`
:cpp:func:`Link::on_state_change <simgrid::s4u::Link::on_state_change_cb>`
- :cpp:func:`Link::on_speed_change <simgrid::s4u::Link::on_bandwidth_change_cb>`
+ :cpp:func:`Link::on_this_state_change <simgrid::s4u::Link::on_this_state_change_cb>`
+ :cpp:func:`Link::on_bandwidth_change <simgrid::s4u::Link::on_bandwidth_change_cb>`
+ :cpp:func:`Link::on_this_bandwidth_change <simgrid::s4u::Link::on_this_bandwidth_change_cb>`
:cpp:func:`Link::on_communication_state_change <simgrid::s4u::Link::on_communication_state_change_cb>`
- :cpp:func:`NetZone::on_creation <simgrid::s4u::NetZone::on_creation_cb>`
:cpp:func:`NetZone::on_seal <simgrid::s4u::NetZone::on_seal_cb>`
.. group-tab:: C++
.. doxygenfunction:: simgrid::s4u::Link::on_bandwidth_change_cb
+ .. doxygenfunction:: simgrid::s4u::Link::on_this_bandwidth_change_cb
.. doxygenfunction:: simgrid::s4u::Link::on_communication_state_change_cb
.. doxygenfunction:: simgrid::s4u::Link::on_creation_cb
.. doxygenfunction:: simgrid::s4u::Link::on_destruction_cb
+ .. doxygenfunction:: simgrid::s4u::Link::on_this_destruction_cb
.. doxygenfunction:: simgrid::s4u::Link::on_state_change_cb
+ .. doxygenfunction:: simgrid::s4u::Link::on_this_state_change_cb
.. _API_s4u_NetZone:
#ifndef DOXYGEN
static xbt::signal<void(Link&)> on_creation;
static xbt::signal<void(Link const&)> on_state_change;
+ xbt::signal<void(Link const&)> on_this_state_change;
static xbt::signal<void(Link const&)> on_bandwidth_change;
+ xbt::signal<void(Link const&)> on_this_bandwidth_change;
static xbt::signal<void(kernel::resource::NetworkAction&, kernel::resource::Action::State)>
on_communication_state_change;
static xbt::signal<void(Link const&)> on_destruction;
+ xbt::signal<void(Link const&)> on_this_destruction;
#endif
public:
/* The signals */
/** @brief Add a callback fired when a new Link is created */
static void on_creation_cb(const std::function<void(Link&)>& cb) { on_creation.connect(cb); }
- /** @brief Add a callback fired when the state of a Link changes (when it is turned on or off) */
+ /** @brief Add a callback fired when the state of any Link changes (when it is turned on or off) */
static void on_state_change_cb(const std::function<void(Link const&)>& cb) { on_state_change.connect(cb); }
- /** @brief Add a callback fired when the bandwidth of a Link changes */
+ /** @brief Add a callback fired when the state of this specific Link changes (when it is turned on or off) */
+ void on_this_state_change_cb(const std::function<void(Link const&)>& cb)
+ {
+ on_this_state_change.connect(cb);
+ }
+ /** @brief Add a callback fired when the bandwidth of any Link changes */
static void on_bandwidth_change_cb(const std::function<void(Link const&)>& cb) { on_bandwidth_change.connect(cb); }
+ /** @brief Add a callback fired when the bandwidth of this specific Link changes */
+ void on_this_bandwidth_change_cb(const std::function<void(Link const&)>& cb)
+ {
+ on_this_bandwidth_change.connect(cb);
+ }
/** @brief Add a callback fired when a communication changes it state (ready/done/cancel) */
static void on_communication_state_change_cb(
const std::function<void(kernel::resource::NetworkAction&, kernel::resource::Action::State)>& cb)
{
on_communication_state_change.connect(cb);
}
- /** @brief Add a callback fired when a Link is destroyed */
+ /** @brief Add a callback fired when any Link is destroyed */
static void on_destruction_cb(const std::function<void(Link const&)>& cb) { on_destruction.connect(cb); }
+ /** @brief Add a callback fired when this specific Link is destroyed */
+ void on_this_destruction_cb(const std::function<void(Link const&)>& cb)
+ {
+ on_this_destruction.connect(cb);
+ }
};
/**
void StandardLinkImpl::destroy()
{
s4u::Link::on_destruction(piface_);
+ piface_.on_this_destruction(piface_);
delete this;
}
void StandardLinkImpl::on_bandwidth_change() const
{
s4u::Link::on_bandwidth_change(piface_);
+ piface_.on_this_bandwidth_change(piface_);
}
void StandardLinkImpl::set_bandwidth_profile(profile::Profile* profile)
simgrid::s4u::Engine::on_simulation_end_cb(&on_simulation_end);
// We may only have one actor on a node. If that actor executes something like
// compute -> recv -> compute
- // the recv operation will not trigger a "CpuAction::on_state_change". This means
+ // the recv operation will not trigger a "Host::on_exec_state_change_cb". This means
// that the next trigger would be the 2nd compute, hence ignoring the idle time
// during the recv call. By updating at the beginning of a compute, we can
// fix that. (If the cpu is not idle, this is not required.)
this->pimpl_cpu_->turn_on();
this->pimpl_->turn_on();
on_state_change(*this);
+ on_this_state_change(*this);
});
}
}
this->pimpl_->turn_off(self);
on_state_change(*this);
+ on_this_state_change(*this);
});
}
}
void Link::turn_on()
{
- kernel::actor::simcall_answered([this]() { this->pimpl_->turn_on(); });
+ kernel::actor::simcall_answered([this]() {
+ this->pimpl_->turn_on();
+ on_state_change(*this);
+ on_this_state_change(*this);
+ });
}
void Link::turn_off()
{
- kernel::actor::simcall_answered([this]() { this->pimpl_->turn_off(); });
+ kernel::actor::simcall_answered([this]() {
+ this->pimpl_->turn_off();
+ on_state_change(*this);
+ on_this_state_change(*this);
+ });
}
Link* Link::seal()
{