A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git]
/
teshsuite
/
s4u
/
listen_async
/
listen_async.cpp
diff --git
a/teshsuite/s4u/listen_async/listen_async.cpp
b/teshsuite/s4u/listen_async/listen_async.cpp
index
991f201
..
c1c5e0a
100644
(file)
--- a/
teshsuite/s4u/listen_async/listen_async.cpp
+++ b/
teshsuite/s4u/listen_async/listen_async.cpp
@@
-1,4
+1,4
@@
-/* Copyright (c) 2017
. The SimGrid Team. All rights reserved.
*/
+/* Copyright (c) 2017
-2019. 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. */
/* 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. */
@@
-15,41
+15,42
@@
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example")
static void server()
{
static void server()
{
- simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by
N
ame("mailbox");
+ simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by
_n
ame("mailbox");
- simgrid::s4u::CommPtr sendComm =
simgrid::s4u::this_actor::isend(mailbox, xbt_strdup
("Some data"), 0);
+ simgrid::s4u::CommPtr sendComm =
mailbox->put_async(new std::string
("Some data"), 0);
xbt_assert(mailbox->listen()); // True (1)
XBT_INFO("Task listen works on regular mailboxes");
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
));
+
std::string* res = static_cast<std::string*>(mailbox->get(
));
- xbt_assert(
not strcmp("Some data", res), "Data received: %s", res
);
+ xbt_assert(
*res == "Some data", "Data received: %s", res->c_str()
);
XBT_INFO("Data successfully received from regular mailbox");
XBT_INFO("Data successfully received from regular mailbox");
-
xbt_free(res)
;
+
delete res
;
sendComm->wait();
sendComm->wait();
- simgrid::s4u::MailboxPtr mailbox2 = simgrid::s4u::Mailbox::by
N
ame("mailbox2");
- mailbox2->set
R
eceiver(simgrid::s4u::Actor::self());
+ simgrid::s4u::MailboxPtr mailbox2 = simgrid::s4u::Mailbox::by
_n
ame("mailbox2");
+ mailbox2->set
_r
eceiver(simgrid::s4u::Actor::self());
-
simgrid::s4u::this_actor::dsend(mailbox2, xbt_strdup("More data"), 0
);
+
mailbox2->put_init(new std::string("More data"), 0)->detach(
);
xbt_assert(mailbox2->listen()); // used to break.
XBT_INFO("Task listen works on asynchronous mailboxes");
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(
not strcmp("More data", res)
);
-
xbt_free(res)
;
+ res = static_cast<
std::string*>(mailbox2->get(
));
+ xbt_assert(
*res == "More data"
);
+
delete res
;
XBT_INFO("Data successfully received from asynchronous mailbox");
}
int main(int argc, char* argv[])
{
XBT_INFO("Data successfully received from asynchronous mailbox");
}
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine
* e = new simgrid::s4u::Engin
e(&argc, argv);
- e
->loadP
latform(argv[1]);
+ simgrid::s4u::Engine
e(&argc, argv);
+ e
.load_p
latform(argv[1]);
- simgrid::s4u::Actor::createActor("test", simgrid::s4u::Host::by_name("Tremblay"), server);
+ simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("Tremblay"), server);
+
+ e.run();
- e->run();
return 0;
}
return 0;
}