Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Examples of CPP versions of Msg
[simgrid.git] / examples / cxx / suspend / DreamMaster.cxx
diff --git a/examples/cxx/suspend/DreamMaster.cxx b/examples/cxx/suspend/DreamMaster.cxx
new file mode 100644 (file)
index 0000000..dd1bab9
--- /dev/null
@@ -0,0 +1,52 @@
+#include "DreamMaster.hpp"\r
+#include "LazyGuy.hpp"\r
+#include <Host.hpp>\r
+#include <HostNotFoundException.hpp>\r
+#include <Msg.hpp>\r
+\r
+#include <iostream>\r
+using namespace std;\r
+\r
+MSG_IMPLEMENT_DYNAMIC(DreamMaster, Process);\r
+\r
+int DreamMaster::main(int argc, char** argv)\r
+{\r
+       \r
+       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl;\r
+       \r
+       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Let's create a lazy guy.";\r
+       \r
+\r
+       LazyGuy* lazy;\r
+\r
+       try\r
+       {\r
+               Host currentHost = Host::currentHost();\r
+       \r
+               cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Current host  name : " << currentHost.getName() << endl;\r
+       \r
+               lazy = new LazyGuy(currentHost,"LazyGuy");\r
+       \r
+               cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Let's wait a little bit..." << endl;\r
+       \r
+               Process::sleep(10.0);\r
+       \r
+               cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Let's wake the lazy guy up! >:) " << endl;\r
+       \r
+               lazy->resume();\r
+       \r
+       \r
+       }\r
+       catch(HostNotFoundException e)\r
+       {\r
+               cerr << e.toString() <<". Stopping Now!" << endl;\r
+               exit(1);\r
+       }\r
+       \r
+       //lazy->migrate(currentHost);\r
+       \r
+       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "OK, goodbye now." << endl;\r
+\r
+       return 0;\r
+       \r
+}
\ No newline at end of file