Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
31316d5bd6ccf9bd4e0e06495236e4af5741d8ff
[simgrid.git] / examples / cxx / autoDestination / Slave.cxx
1 #include "Slave.hpp"\r
2 #include "FinalizeTask.hpp"\r
3 #include "BasicTask.hpp"\r
4 \r
5 #include <Host.hpp>\r
6 #include <HostNotFoundException.hpp>\r
7 \r
8 #include <Msg.hpp>\r
9 \r
10 MSG_IMPLEMENT_DYNAMIC(Slave, Process);\r
11 \r
12 int Slave::main(int argc, char** argv)\r
13 {\r
14         info("Hello");\r
15         \r
16         Task* receivedTask;\r
17         BasicTask* basicTask;\r
18         \r
19         while(true) \r
20         { \r
21                 receivedTask = Task::receive(); \r
22         \r
23                 if(receivedTask->isInstanceOf("FinalizeTask")) \r
24                 {\r
25                         delete receivedTask;\r
26                         break;\r
27                 }\r
28         \r
29                 basicTask = reinterpret_cast<BasicTask*>(receivedTask);\r
30         \r
31                 info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" "));\r
32         \r
33                 info(TEXT_("Processing \"") + TEXT_(basicTask->getName()) + TEXT_("\" "));\r
34                 \r
35                 basicTask->execute();\r
36                 \r
37                 info(TEXT_("\"") + TEXT_(basicTask->getName()) + TEXT_("\" done "));\r
38         \r
39                 delete basicTask;\r
40         }\r
41                 \r
42         info("Received Finalize. I'm done. See you!");\r
43         \r
44         delete this;\r
45 \r
46         return 0;\r
47 }