From e16ebb1333db2cee332bbfed4098df88777cec22 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 6 Jul 2017 01:46:54 +0200 Subject: [PATCH] fix the API to isend detach() and speak about it in ChangeLog --- ChangeLog | 3 +++ examples/s4u/dht-chord/node.cpp | 10 +++++----- include/simgrid/s4u/Actor.hpp | 1 - include/simgrid/s4u/Comm.hpp | 6 +++--- src/s4u/s4u_actor.cpp | 5 ----- src/s4u/s4u_comm.cpp | 11 ++++------- teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp | 4 ++-- teshsuite/s4u/listen_async/listen_async.cpp | 2 +- 8 files changed, 18 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7ca01b959..34788ca4f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 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. diff --git a/examples/s4u/dht-chord/node.cpp b/examples/s4u/dht-chord/node.cpp index 02c37e43b6..866947842d 100644 --- a/examples/s4u/dht-chord/node.cpp +++ b/examples/s4u/dht-chord/node.cpp @@ -389,7 +389,7 @@ void Node::remoteNotify(int notify_id, int predecessor_candidate_id) // 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. */ @@ -431,14 +431,14 @@ void Node::handleMessage(ChordMessage* message) 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; @@ -448,7 +448,7 @@ void Node::handleMessage(ChordMessage* message) 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: @@ -486,7 +486,7 @@ void Node::handleMessage(ChordMessage* message) 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: diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index a61160fb15..333bd9c2e2 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -318,7 +318,6 @@ template inline void sleep_for(std::chrono::durationsetRemains(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) diff --git a/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp b/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp index ac41a68aa1..bad54f17a8 100644 --- a/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp +++ b/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp @@ -76,12 +76,12 @@ static void sender(std::vector args) 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]); diff --git a/teshsuite/s4u/listen_async/listen_async.cpp b/teshsuite/s4u/listen_async/listen_async.cpp index c1a0364c0c..c4ad656ee7 100644 --- a/teshsuite/s4u/listen_async/listen_async.cpp +++ b/teshsuite/s4u/listen_async/listen_async.cpp @@ -31,7 +31,7 @@ static void server() 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"); -- 2.20.1