Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
All of the examples use now the StringHelp class to simplify the string manipulation.
[simgrid.git] / examples / cxx / comm_time / Slave.cxx
1 #include "Slave.hpp"\r
2 #include "FinalizeTask.hpp"\r
3 #include "CommTimeTask.hpp"\r
4 #include <Host.hpp>\r
5 #include <HostNotFoundException.hpp>\r
6 #include <Msg.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         while(true) \r
17         {\r
18                 double time1 = getClock();       \r
19                 Task* t = Task::get(0); \r
20                 double time2 = getClock();\r
21         \r
22                 if(t->isInstanceOf("FinalizeTask")) \r
23                 {\r
24                         delete t;\r
25                         break;\r
26                 }\r
27                 \r
28                 CommTimeTask* task = reinterpret_cast<CommTimeTask*>(t);\r
29         \r
30                 if(time1 < task->getTime())\r
31                         time1 = task->getTime();\r
32                         \r
33                 //info(TEXT_("Processing \"") + TEXT_(task->getName()) + TEXT_("\" ") + TEXT_(getHost().getName()) + TEXT_(" (Communication time : ") + TEXT_((time2 - time1)) + TEXT_(")"));\r
34          \r
35                 task->execute();\r
36                 \r
37                 delete task;\r
38         }\r
39         \r
40         info(TEXT_("Received Finalize. I'm done. See you!"));\r
41         \r
42         delete this;\r
43         return 0;\r
44         \r
45 }