+/* Copyright (c) 2017. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
/* Bug report: https://github.com/simgrid/simgrid/issues/40
*
* Task.listen used to be on async mailboxes as it always returned false.
{
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName("mailbox");
- simgrid::s4u::this_actor::isend(mailbox, xbt_strdup("Some data"), 0);
+ simgrid::s4u::CommPtr sendComm = mailbox->send_async(xbt_strdup("Some data"), 0);
xbt_assert(mailbox->listen()); // True (1)
XBT_INFO("Task listen works on regular mailboxes");
char* res = static_cast<char*>(simgrid::s4u::this_actor::recv(mailbox));
- xbt_assert(!strcmp("Some data", res), "Data received: %s", res);
+ xbt_assert(not strcmp("Some data", res), "Data received: %s", res);
XBT_INFO("Data successfully received from regular mailbox");
xbt_free(res);
+ sendComm->wait();
simgrid::s4u::MailboxPtr mailbox2 = simgrid::s4u::Mailbox::byName("mailbox2");
mailbox2->setReceiver(simgrid::s4u::Actor::self());
- simgrid::s4u::this_actor::isend(mailbox2, xbt_strdup("More data"), 0);
+ mailbox2->send_init(xbt_strdup("More data"), 0)->detach();
xbt_assert(mailbox2->listen()); // used to break.
XBT_INFO("Task listen works on asynchronous mailboxes");
res = static_cast<char*>(simgrid::s4u::this_actor::recv(mailbox2));
- xbt_assert(!strcmp("More data", res));
+ xbt_assert(not strcmp("More data", res));
xbt_free(res);
XBT_INFO("Data successfully received from asynchronous mailbox");
simgrid::s4u::Actor::createActor("test", simgrid::s4u::Host::by_name("Tremblay"), server);
e->run();
+
+ delete e;
return 0;
}