namespace simgrid::s4u {
xbt::signal<void(Comm const&)> Comm::on_send;
xbt::signal<void(Comm const&)> Comm::on_recv;
-xbt::signal<void(Comm const&)> Comm::on_start;
CommPtr Comm::set_copy_data_callback(const std::function<void(kernel::activity::CommImpl*, void*, size_t)>& callback)
{
xbt_assert(src_buff_ == nullptr && dst_buff_ == nullptr,
"Direct host-to-host communications cannot carry any data.");
XBT_DEBUG("host-to-host Comm. Pimpl already created and set, just start it.");
- on_send(*this);
- on_recv(*this);
+ on_start(*this);
+ on_this_start(*this);
kernel::actor::simcall_answered([this] {
pimpl_->set_state(kernel::activity::State::READY);
boost::static_pointer_cast<kernel::activity::CommImpl>(pimpl_)->start();
});
} else if (src_buff_ != nullptr) { // Sender side
on_send(*this);
+ on_this_send(*this);
kernel::actor::CommIsendSimcall observer{sender_,
mailbox_->get_impl(),
remains_,
} else if (dst_buff_ != nullptr) { // Receiver side
xbt_assert(not detached_, "Receive cannot be detached");
on_recv(*this);
+ on_this_recv(*this);
kernel::actor::CommIrecvSimcall observer{receiver_,
mailbox_->get_impl(),
static_cast<unsigned char*>(dst_buff_),
pimpl_->set_iface(this);
pimpl_->set_actor(sender_);
// Only throw the signal when both sides are here and the status is READY
- if (pimpl_->get_state() != kernel::activity::State::WAITING)
+ if (pimpl_->get_state() != kernel::activity::State::WAITING) {
on_start(*this);
+ on_this_start(*this);
+ }
}
state_ = State::STARTED;
return start()->wait_for(timeout); // In the case of host2host comm, do it in two simcalls
} else if (src_buff_ != nullptr) {
on_send(*this);
+ on_this_send(*this);
send(sender_, mailbox_, remains_, rate_, src_buff_, src_buff_size_, match_fun_, copy_data_function_,
get_data<void>(), timeout);
} else { // Receiver
on_recv(*this);
+ on_this_recv(*this);
recv(receiver_, mailbox_, dst_buff_, &dst_buff_size_, match_fun_, copy_data_function_, get_data<void>(),
timeout, rate_);
}
void Comm::wait_all(const std::vector<CommPtr>& comms)
{
// TODO: this should be a simcall or something
- for (auto& comm : comms)
+ for (const auto& comm : comms)
comm->wait();
}