X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fc6fb42c354e8c1c7f6f6526c560ba858d75c027..dadfefc9f3cc6cf0fc28a9025307f9f08dc4ac96:/examples/s4u/launching/s4u_launching.cpp diff --git a/examples/s4u/launching/s4u_launching.cpp b/examples/s4u/launching/s4u_launching.cpp index 3c9b931486..49e2a4c65f 100644 --- a/examples/s4u/launching/s4u_launching.cpp +++ b/examples/s4u/launching/s4u_launching.cpp @@ -35,20 +35,20 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_launching_test, "The logging channel used in th */ class Sender { public: - const char *msg = "GaBuZoMeu"; - Sender() { + std::string msg = "GaBuZoMeu"; + explicit Sender() { /* Constructor used when no parameter is passed to the actor */ }; - Sender(std::vector args) { + explicit Sender(std::vector args) { /* This constructor is used when we pass parameters to the actor */ if (args.size() > 0) - msg = args[0].c_str(); + msg = args[0]; } void operator()() { XBT_INFO("Hello s4u, I have something to send"); simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName("mb42"); - simgrid::s4u::this_actor::send(mailbox, xbt_strdup(msg), strlen(msg)); + simgrid::s4u::this_actor::send(mailbox, xbt_strdup(msg.c_str()), msg.size()); XBT_INFO("I'm done. See you."); } }; @@ -63,15 +63,21 @@ class Receiver { public: simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName("thingy"); - Receiver() {}; - Receiver(std::vector args) { + explicit Receiver() = default; + explicit Receiver(std::vector args) { /* This constructor is used when we pass parameters to the actor */ /* as with argc/argv, args[0] is the actor's name, so the first parameter is args[1] */ + + /* FIXME: this is a bug as this does not happen when starting the process directly + * We should fix it by not adding the process name as argv[0] from the deployment file, + * which is useless anyway since it's always the function name in this setting. + * But this will break MSG... + */ if (args.size() > 1) mailbox = simgrid::s4u::Mailbox::byName(args[1]); } void operator()() { - XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->getName()); + XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->name()); char *msg1 = static_cast(simgrid::s4u::this_actor::recv(mailbox)); char *msg2 = static_cast(simgrid::s4u::this_actor::recv(mailbox));