Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c7ebc3138d50e528256273ff23cefd6a6d454415
[simgrid.git] / examples / cxx / explicitDestination / 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 using namespace std;\r
10 \r
11 MSG_IMPLEMENT_DYNAMIC(Slave, Process);\r
12 \r
13 int Slave::main(int argc, char** argv)\r
14 {\r
15         info("Hello");\r
16         \r
17         Task* receivedTask;\r
18         BasicTask* basicTask;\r
19         \r
20         while(true) \r
21         { \r
22                 receivedTask = Task::receive(Host::currentHost().getName());    \r
23         \r
24                 if(receivedTask->isInstanceOf("FinalizeTask")) \r
25                 {\r
26                         delete receivedTask;\r
27                         break;\r
28                 }\r
29         \r
30                 basicTask = reinterpret_cast<BasicTask*>(receivedTask);\r
31         \r
32                 info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" "));\r
33         \r
34                 info(TEXT_("Processing \"") + TEXT_(basicTask->getName()) + TEXT_("\" "));\r
35                 basicTask->execute();\r
36                 info(TEXT_("\"") + TEXT_(basicTask->getName()) + TEXT_("\" done "));\r
37         \r
38                 delete basicTask;\r
39         }\r
40                 \r
41         info("Received Finalize. I'm done. See you!");\r
42         \r
43         delete this;\r
44         return 0;\r
45 }