Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
delete the process at the end of the main method
[simgrid.git] / examples / cxx / suspend / DreamMaster.cxx
1 #include "DreamMaster.hpp"\r
2 #include "LazyGuy.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(DreamMaster, Process);\r
11 \r
12 int DreamMaster::main(int argc, char** argv)\r
13 {\r
14         \r
15         cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl;\r
16         \r
17         cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Let's create a lazy guy.";\r
18         \r
19 \r
20         LazyGuy* lazy;\r
21 \r
22         try\r
23         {\r
24                 Host currentHost = Host::currentHost();\r
25         \r
26                 cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Current host  name : " << currentHost.getName() << endl;\r
27         \r
28                 lazy = new LazyGuy(currentHost,"LazyGuy");\r
29         \r
30                 cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Let's wait a little bit..." << endl;\r
31         \r
32                 Process::sleep(10.0);\r
33         \r
34                 cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Let's wake the lazy guy up! >:) " << endl;\r
35         \r
36                 lazy->resume();\r
37         \r
38         \r
39         }\r
40         catch(HostNotFoundException e)\r
41         {\r
42                 cerr << e.toString() <<". Stopping Now!" << endl;\r
43                 exit(1);\r
44         }\r
45         \r
46         //lazy->migrate(currentHost);\r
47         \r
48         cout <<"[" << getName() << ":" << getHost().getName() << "] " << "OK, goodbye now." << endl;\r
49 \r
50         delete this;\r
51 \r
52         return 0;\r
53         \r
54 }