XBT_DEBUG("send from mailbox %p", mbox);
/* Prepare a synchro describing us, so that it gets passed to the user-provided filter of other side */
- simgrid::kernel::activity::CommImplPtr this_comm(new simgrid::kernel::activity::CommImpl());
- this_comm->set_type(simgrid::kernel::activity::CommImpl::Type::SEND);
+ simgrid::kernel::activity::CommImplPtr this_comm(
+ new simgrid::kernel::activity::CommImpl(simgrid::kernel::activity::CommImpl::Type::SEND));
/* Look for communication synchro matching our needs. We also provide a description of
* ourself so that the other side also gets a chance of choosing if it wants to match with us.
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
double rate)
{
- simgrid::kernel::activity::CommImplPtr this_synchro(new simgrid::kernel::activity::CommImpl());
- this_synchro->set_type(simgrid::kernel::activity::CommImpl::Type::RECEIVE);
+ simgrid::kernel::activity::CommImplPtr this_synchro(
+ new simgrid::kernel::activity::CommImpl(simgrid::kernel::activity::CommImpl::Type::RECEIVE));
XBT_DEBUG("recv from mbox %p. this_synchro=%p", mbox, this_synchro.get());
simgrid::kernel::activity::CommImplPtr other_comm;
return *this;
}
-CommImpl::CommImpl(s4u::Host* from, s4u::Host* to, double bytes) : size_(bytes), detached_(true), from_(from), to_(to)
+CommImpl::CommImpl(s4u::Host* from, s4u::Host* to, double bytes)
+ : size_(bytes), detached_(true), type_(Type::SEND), from_(from), to_(to)
{
state_ = State::READY;
}
MailboxImpl* mbox_ = nullptr; /* Rendez-vous where the comm is queued */
public:
- CommImpl() = default;
- CommImpl(s4u::Host* from, s4u::Host* to, double bytes);
-
enum class Type { SEND = 0, RECEIVE, READY, DONE };
+ CommImpl(Type type) : type_(type) {}
+ CommImpl(s4u::Host* from, s4u::Host* to, double bytes);
+
CommImpl& set_type(CommImpl::Type type);
CommImpl& set_size(double size);
CommImpl& set_src_buff(unsigned char* buff, size_t size);
CommImplPtr this_comm;
CommImpl::Type smx_type;
if (type == 1) {
- this_comm = CommImplPtr(new CommImpl());
- this_comm->set_type(CommImpl::Type::SEND);
+ this_comm = CommImplPtr(new CommImpl(CommImpl::Type::SEND));
smx_type = CommImpl::Type::RECEIVE;
} else {
- this_comm = CommImplPtr(new CommImpl());
- this_comm->set_type(CommImpl::Type::RECEIVE);
+ this_comm = CommImplPtr(new CommImpl(CommImpl::Type::RECEIVE));
smx_type = CommImpl::Type::SEND;
}
CommImplPtr other_comm = nullptr;