Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into S4U
[simgrid.git] / examples / s4u / dumb / s4u_test.cpp
1 /* Copyright (c) 2006-2015. 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 "simgrid/s4u.h"
7
8 using namespace simgrid;
9 using namespace s4u;
10
11 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
12
13 class Worker : Process {
14 public:
15         Worker(const char*procname, Host *host,int argc, char **argv)
16                         : s4u::Process(procname,host,argc,argv){}
17
18         int main(int argc, char **argv) {
19                 XBT_INFO("Hello s4u, I'm ready to serve");
20
21                 char *msg = recvstr(*Channel::byName("worker"));
22                 XBT_INFO("I received '%s'",msg);
23                 XBT_INFO("I'm done. See you.");
24                 return 1;
25         }
26 };
27
28 class Master : Process {
29 public:
30         Master(const char*procname, Host *host,int argc, char **argv)
31                         : Process(procname,host,argc,argv){}
32
33         int main(int argc, char **argv) {
34                 XBT_INFO("Hello s4u, I have something to send");
35                 sendstr(*Channel::byName("worker"),"GaBuZoMeu");
36
37                 XBT_INFO("I'm done. See you.");
38                 return 1;
39         }
40 };
41
42
43 int main(int argc, char **argv) {
44         Engine *e = new Engine(&argc,argv);
45         e->loadPlatform("../../platforms/two_hosts_platform.xml");
46
47         new Worker("worker", Host::byName("host0"), 0, NULL);
48         new Master("master", Host::byName("host1"), 0, NULL);
49         e->run();
50         return 0;
51 }