Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename a C++-only header with the '.hpp' suffix
[simgrid.git] / examples / s4u / basic / s4u_basic.h
1 /* Copyright (c) 2006-2016. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include <xbt/sysdep.h>
7
8 #include <simgrid/s4u.hpp>
9
10 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
11
12 class Worker {
13 public:
14   Worker() {};
15   Worker(std::vector<std::string> args) {}
16   void operator()() {
17     XBT_INFO("Hello s4u, I'm ready to serve");
18     char *msg = static_cast<char*>(simgrid::s4u::this_actor::recv(
19       *simgrid::s4u::Mailbox::byName("worker")));
20     XBT_INFO("I received '%s'",msg);
21     XBT_INFO("I'm done. See you.");
22   }
23 };
24
25 class Master {
26 public:
27   Master() {};
28   Master(std::vector<std::string> args) {}
29   void operator()() {
30     const char *msg = "GaBuZoMeu";
31     XBT_INFO("Hello s4u, I have something to send");
32     simgrid::s4u::this_actor::send(*simgrid::s4u::Mailbox::byName("worker"), xbt_strdup(msg), strlen(msg));
33     XBT_INFO("I'm done. See you.");
34   }
35 };