SimGrid (3.17) UNRELEASED (release target: September 22 2017)
+ S4U
+ - start and forget about isend comms with detach()
+
SimGrid (3.16) Released June 22. 2017.
The Blooming Spring Release: developments are budding.
// send a "Notify" request to notify_id
XBT_DEBUG("Sending a 'Notify' request to %d", notify_id);
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(notify_id));
- simgrid::s4u::this_actor::dsend(mailbox, message, 10);
+ simgrid::s4u::this_actor::isend(mailbox, message, 10)->detach();
}
/* This function is called periodically. It checks the immediate successor of the current node. */
message->answer_id = fingers_[0];
XBT_DEBUG("Sending back a 'Find Successor Answer' to %s (mailbox %s): the successor of %d is %d",
message->issuer_host_name.c_str(), message->answer_to->name(), message->request_id, message->answer_id);
- simgrid::s4u::this_actor::dsend(message->answer_to, message, 10);
+ simgrid::s4u::this_actor::isend(message->answer_to, message, 10)->detach();
} else {
// otherwise, forward the request to the closest preceding finger in my table
int closest = closestPrecedingFinger(message->request_id);
XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
message->request_id, closest);
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(closest));
- simgrid::s4u::this_actor::dsend(mailbox, message, 10);
+ simgrid::s4u::this_actor::isend(mailbox, message, 10)->detach();
}
break;
message->answer_id = pred_id_;
XBT_DEBUG("Sending back a 'Get Predecessor Answer' to %s via mailbox '%s': my predecessor is %d",
message->issuer_host_name.c_str(), message->answer_to->name(), message->answer_id);
- simgrid::s4u::this_actor::dsend(message->answer_to, message, 10);
+ simgrid::s4u::this_actor::isend(message->answer_to, message, 10)->detach();
break;
case NOTIFY:
message->type = PREDECESSOR_ALIVE_ANSWER;
XBT_DEBUG("Sending back a 'Predecessor Alive Answer' to %s (mailbox %s)",
message->issuer_host_name.c_str(), message->answer_to->name());
- simgrid::s4u::this_actor::dsend(message->answer_to, message, 10);
+ simgrid::s4u::this_actor::isend(message->answer_to, message, 10)->detach();
break;
default:
XBT_PUBLIC(void) send(MailboxPtr chan, void* payload, double simulatedSize, double timeout);
XBT_PUBLIC(CommPtr) isend(MailboxPtr chan, void* payload, double simulatedSize);
- XBT_PUBLIC(void) dsend(MailboxPtr chan, void* payload, double simulatedSize);
/** @brief Returns the actor ID of the current actor (same as pid). */
XBT_PUBLIC(aid_t) pid();
static CommPtr recv_init(MailboxPtr from);
/** Creates and start an async recv to the mailbox @p from */
static CommPtr recv_async(MailboxPtr from, void** data);
- /** Creates and start a detached send to the mailbox @p dest
- * TODO: make it possible to detach an already created comm */
- static void send_detached(MailboxPtr dest, void* data, int simulatedSize);
void start() override;
void wait() override;
void wait(double timeout) override;
+ /** Start the comm, and ignore its result. It can be completely forgotten after that. */
+ void detach();
+
/** Sets the maximal communication rate (in byte/sec). Must be done before start */
void setRate(double rate);
return Comm::send_async(chan, payload, simulatedSize);
}
-void dsend(MailboxPtr chan, void* payload, double simulatedSize)
-{
- Comm::send_detached(chan, payload, simulatedSize);
-}
-
CommPtr irecv(MailboxPtr chan, void** data)
{
return Comm::recv_async(chan, data);
state_ = finished;
}
-void Comm::send_detached(MailboxPtr dest, void* data, int simulatedSize)
+void Comm::detach()
{
- s4u::CommPtr res = CommPtr(s4u::Comm::send_init(dest));
- res->setRemains(simulatedSize);
- res->srcBuff_ = data;
- res->srcBuffSize_ = sizeof(void*);
- res->detached_ = true;
- res->start();
+ xbt_assert(state_ == inited, "You cannot detach communications once they are started.");
+ xbt_assert(srcBuff_ != nullptr && srcBuffSize_ != 0, "You can only detach sends, not recvs");
+ detached_ = true;
}
s4u::CommPtr Comm::send_async(MailboxPtr dest, void* data, int simulatedSize)
case 'd':
XBT_INFO("Test %d: d (detached send)", test);
- simgrid::s4u::this_actor::dsend(mbox, (void*)mboxName, 42.0);
+ simgrid::s4u::this_actor::isend(mbox, (void*)mboxName, 42.0)->detach();
break;
case 'D':
XBT_INFO("Test %d: D (sleep + detached send)", test);
simgrid::s4u::this_actor::sleep_for(0.5);
- simgrid::s4u::this_actor::dsend(mbox, (void*)mboxName, 42.0);
+ simgrid::s4u::this_actor::isend(mbox, (void*)mboxName, 42.0)->detach();
break;
default:
xbt_die("Unknown sender spec for test %d: '%c'", test, args[0][test - 1]);
simgrid::s4u::MailboxPtr mailbox2 = simgrid::s4u::Mailbox::byName("mailbox2");
mailbox2->setReceiver(simgrid::s4u::Actor::self());
- simgrid::s4u::this_actor::dsend(mailbox2, xbt_strdup("More data"), 0);
+ simgrid::s4u::this_actor::isend(mailbox2, xbt_strdup("More data"), 0)->detach();
xbt_assert(mailbox2->listen()); // used to break.
XBT_INFO("Task listen works on asynchronous mailboxes");