~Comm() override;
+ /*! Creates a communication that bypasses the mailbox mechanism. */
+ static CommPtr sendto_init();
/*! Creates a communication beween the two given hosts, bypassing the mailbox mechanism. */
static CommPtr sendto_init(Host* from, Host* to);
/** Do an asynchronous communication between two arbitrary hosts.
return detach();
}
+ /** Set the source and destination of communications that bypass the mailbox mechanism */
+ CommPtr set_from(Host* from);
+ CommPtr set_to(Host* to);
+
/** Sets the maximal communication rate (in byte/sec). Must be done before start */
CommPtr set_rate(double rate);
return comms.size();
}
+CommPtr Comm::set_from(Host* from)
+{
+ xbt_assert(state_ == State::INITED || state_ == State::STARTING,
+ "Cannot change the source of a Comm once it's started (state: %s)", to_c_str(state_));
+ from_ = from;
+ // Setting 'from_' may allow to start the activity, let's try
+ vetoable_start();
+
+ return this;
+}
+
+CommPtr Comm::set_to(Host* to)
+{
+ xbt_assert(state_ == State::INITED || state_ == State::STARTING,
+ "Cannot change the destination of a Comm once it's started (state: %s)", to_c_str(state_));
+ to_ = to;
+ // Setting 'to_' may allow to start the activity, let's try
+ vetoable_start();
+
+ return this;
+}
+
CommPtr Comm::set_rate(double rate)
{
xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication started (not implemented)",
return this;
}
-CommPtr Comm::sendto_init(Host* from, Host* to)
+CommPtr Comm::sendto_init()
{
CommPtr res(new Comm());
res->sender_ = kernel::actor::ActorImpl::self();
+ return res;
+}
+
+CommPtr Comm::sendto_init(Host* from, Host* to)
+{
+ auto res = Comm::sendto_init();
res->from_ = from;
res->to_ = to;