Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change consecutive to the renaming of the C++ wrappers
[simgrid.git] / examples / cxx / comm_time / Slave.cxx
1 #include "Slave.hpp"
2 #include "FinalizeTask.hpp"
3 #include "CommTimeTask.hpp"
4 #include <MsgHost.hpp>
5 #include <HostNotFoundException.hpp>
6 #include <Msg.hpp>
7
8 #include <Msg.hpp>
9
10 MSG_IMPLEMENT_DYNAMIC(Slave, Process)
11
12 int Slave::main(int argc, char** argv)
13 {
14         info("Hello");
15         
16         while(true) 
17         {
18                 double time1 = getClock();       
19                 Task* t = Task::get(0); 
20                 double time2 = getClock();
21         
22                 if(t->isInstanceOf("FinalizeTask")) 
23                 {
24                         delete t;
25                         break;
26                 }
27                 
28                 CommTimeTask* task = reinterpret_cast<CommTimeTask*>(t);
29         
30                 if(time1 < task->getTime())
31                         time1 = task->getTime();
32                         
33                 //info(TEXT_("Processing \"") + TEXT_(task->getName()) + TEXT_("\" ") + TEXT_(getHost().getName()) + TEXT_(" (Communication time : ") + TEXT_((time2 - time1)) + TEXT_(")"));
34          
35                 task->execute();
36                 
37                 delete task;
38         }
39         
40         info(TEXT_("Received Finalize. I'm done. See you!"));
41         
42         delete this;
43         return 0;
44         
45 }