Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Let simgrid.dtd to be accessible from the web in order to enable automatic validation...
[simgrid.git] / examples / cxx / ping_pong / Receiver.cxx
1 #include "Receiver.hpp"
2 #include "PingPongTask.hpp"
3 #include <MsgHost.hpp>
4 #include <HostNotFoundException.hpp>
5 #include <Msg.hpp>
6
7 #include <Msg.hpp>
8
9 MSG_IMPLEMENT_DYNAMIC(Receiver, Process)
10
11 const double commSizeLat = 1;
12 const double commSizeBw = 100000000;
13
14 int Receiver::main(int argc, char** argv)
15 {
16         info("Hello");
17         double communicationTime=0;
18         double time = getClock();
19         StringHelper bw;
20         
21         info("Try to get a task");
22         
23         PingPongTask* task = reinterpret_cast<PingPongTask*>(Task::get(0));
24         
25         double timeGot = getClock();
26         double timeSent = task->getTime();
27         
28         delete task;
29         
30         info(TEXT_("Got at time ") + TEXT_(timeGot));
31         info(TEXT_("Was sent at time ") + TEXT_(timeSent));
32         
33         time = timeSent;
34         
35         communicationTime = timeGot - time;
36         
37         info(TEXT_( "Communication time : ") + TEXT_(communicationTime));
38         
39         info(TEXT_(" --- BW ") + bw.append(commSizeBw/communicationTime,"%07lf") + TEXT_(" ----"));
40         
41         info("Goodbye!");
42         
43         delete this;
44
45         return 0;
46 }