Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
last changes of cpp wrappers examples
[simgrid.git] / examples / cxx / ping_pong / Sender.cxx
1 #include "Sender.hpp"
2 #include "PingPongTask.hpp"
3 #include <Host.hpp>
4 #include <HostNotFoundException.hpp>
5 #include <Msg.hpp>
6
7 #include <Msg.hpp>
8 using namespace std;
9
10 const double commSizeLat = 1;
11 const double commSizeBw = 100000000;
12
13 MSG_IMPLEMENT_DYNAMIC(Sender, Process)
14
15 int Sender::main(int argc, char** argv)
16 {
17         info("Hello");
18         
19         int hostCount = argc;
20         
21         info(TEXT_("Host count : ") + TEXT_(hostCount));
22         
23         Host* hostTable = new Host[hostCount]; 
24         double time;
25         double computeDuration = 0;
26         PingPongTask* task;
27         
28         for(int pos = 0; pos < argc ; pos++) 
29         {
30                 try 
31                 {
32                         hostTable[pos] = Host::getByName(argv[pos]);
33                 } 
34                 catch(HostNotFoundException e) 
35                 {
36                         error(TEXT_(e.toString()) + TEXT_(". Stopping Now!"));
37                         exit(1);
38                 }
39         }
40         
41         for (int pos = 0; pos < hostCount; pos++) 
42         { 
43                 time = getClock(); 
44         
45                 info(TEXT_("Sender time : ") + TEXT_(time));
46         
47                 task = new PingPongTask("no name",computeDuration,commSizeLat);
48                 task->setTime(time);
49         
50                 hostTable[pos].put(0,task);
51         } 
52         
53         info("Goodbye!");
54
55         
56         delete[] hostTable;
57
58         delete this;
59
60         return 0;
61     
62 }
63