Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
delete the process at the end of the main method
[simgrid.git] / examples / cxx / ping_pong / Receiver.cxx
1 #include "Receiver.hpp"\r
2 #include "PingPongTask.hpp"\r
3 #include <Host.hpp>\r
4 #include <HostNotFoundException.hpp>\r
5 #include <Msg.hpp>\r
6 \r
7 #include <iostream>\r
8 using namespace std;\r
9 \r
10 MSG_IMPLEMENT_DYNAMIC(Receiver, Process);\r
11 \r
12 const double commSizeLat = 1;\r
13 const double commSizeBw = 100000000;\r
14 \r
15 int Receiver::main(int argc, char** argv)\r
16 {\r
17         cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl;\r
18         double communicationTime=0;\r
19         double time = getClock();\r
20         \r
21         cout <<"[" << getName() << ":" << getHost().getName() << "try to get a task" << endl;\r
22         \r
23         PingPongTask* task = reinterpret_cast<PingPongTask*>(Task::get(0));\r
24         \r
25         double timeGot = getClock();\r
26         double timeSent = task->getTime();\r
27         \r
28         delete task;\r
29         \r
30         cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Got at time " << timeGot << endl;\r
31         cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Was sent at time " << timeSent << endl;\r
32         \r
33         time = timeSent;\r
34         \r
35         communicationTime = timeGot - time;\r
36         \r
37         cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Communication time : " << communicationTime << endl;\r
38         \r
39         cout <<"[" << getName() << ":" << getHost().getName() << "] " << " --- bw " << commSizeBw/communicationTime << " ----" << endl;\r
40         \r
41         cout <<"[" << getName() << ":" << getHost().getName() << "] " << "goodbye!" << endl;\r
42         \r
43         delete this;\r
44 \r
45         return 0;\r
46 }