+// This declares a logging channel so that XBT_INFO can be used later
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_launching_test, "The logging channel used in this example");
+
+
+/* Declares a first class of actors which sends a message to the mailbox 'mb42'.
+ * The sent message is what was passed as parameter on creation (or 'GaBuZoMeu' by default)
+ *
+ * Later, this actor class is instantiated twice in the simulation.
+ */
+class Sender {
+public:
+ const char *msg = "GaBuZoMeu";
+ Sender() {
+ /* Constructor used when no parameter is passed to the actor */
+ };
+ Sender(std::vector<std::string> args) {
+ /* This constructor is used when we pass parameters to the actor */
+ if (args.size() > 0)
+ msg = args[0].c_str();
+ }
+ 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));
+ XBT_INFO("I'm done. See you.");
+ }
+};
+
+
+/* Declares a second class of actor which receive two messages on the mailbox which
+ * name is passed as parameter ('thingy' by default, ie the wrong one).
+ *
+ * Later, this actor class is instantiated once in the simulation.
+ */
+class Receiver {
+public:
+ simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName("thingy");
+
+ Receiver() {};
+ Receiver(std::vector<std::string> 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] */
+ if (args.size() > 1)
+ mailbox = simgrid::s4u::Mailbox::byName(args[1].c_str());
+ }
+ void operator()() {
+ XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->getName());
+
+ char *msg1 = static_cast<char*>(simgrid::s4u::this_actor::recv(mailbox));
+ char *msg2 = static_cast<char*>(simgrid::s4u::this_actor::recv(mailbox));
+ XBT_INFO("I received '%s' and '%s'",msg1,msg2);
+ XBT_INFO("I'm done. See you.");
+ }
+};