- if (src_buff_ != nullptr) { // Sender side
- on_sender_start(*Actor::self());
- pimpl_ = simcall_comm_isend(sender_, mailbox_->get_impl(), remains_, rate_, src_buff_, src_buff_size_, match_fun_,
- clean_fun_, copy_data_function_, get_user_data(), detached_);
+CommPtr Comm::sendto_init(Host* from, Host* to)
+{
+ auto res = Comm::sendto_init();
+ res->from_ = from;
+ res->to_ = to;
+
+ return res;
+}
+
+CommPtr Comm::sendto_async(Host* from, Host* to, uint64_t simulated_size_in_bytes)
+{
+ auto res = Comm::sendto_init(from, to)->set_payload_size(simulated_size_in_bytes);
+ res->vetoable_start();
+ return res;
+}
+
+void Comm::sendto(Host* from, Host* to, uint64_t simulated_size_in_bytes)
+{
+ sendto_async(from, to, simulated_size_in_bytes)->wait();
+}
+
+Comm* Comm::start()
+{
+ xbt_assert(get_state() == State::INITED || get_state() == State::STARTING,
+ "You cannot use %s() once your communication started (not implemented)", __FUNCTION__);
+ if (from_ != nullptr || to_ != nullptr) {
+ xbt_assert(from_ != nullptr && to_ != nullptr, "When either from_ or to_ is specified, both must be.");
+ xbt_assert(src_buff_ == nullptr && dst_buff_ == nullptr,
+ "Direct host-to-host communications cannot carry any data.");
+ pimpl_ = kernel::actor::simcall([this] {
+ kernel::activity::CommImplPtr res(new kernel::activity::CommImpl(this->from_, this->to_, this->get_remaining()));
+ res->start();
+ return res;
+ });
+
+ } else if (src_buff_ != nullptr) { // Sender side
+ on_send(*this);
+ kernel::actor::CommIsendSimcall observer{sender_,
+ mailbox_->get_impl(),
+ remains_,
+ rate_,
+ static_cast<unsigned char*>(src_buff_),
+ src_buff_size_,
+ match_fun_,
+ clean_fun_,
+ copy_data_function_,
+ get_data<void>(),
+ detached_};
+ pimpl_ = kernel::actor::simcall([&observer] { return kernel::activity::CommImpl::isend(&observer); }, &observer);