Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Examples of CPP versions of Msg
[simgrid.git] / examples / cxx / suspend / LazyGuy.cxx
diff --git a/examples/cxx/suspend/LazyGuy.cxx b/examples/cxx/suspend/LazyGuy.cxx
new file mode 100644 (file)
index 0000000..ba12220
--- /dev/null
@@ -0,0 +1,24 @@
+#include "LazyGuy.hpp"\r
+#include <Host.hpp>\r
+\r
+#include <iostream>\r
+using namespace std;\r
+\r
+MSG_IMPLEMENT_DYNAMIC(LazyGuy, Process);\r
+\r
+int LazyGuy::main(int argc, char** argv)\r
+{\r
+       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello !" << endl;\r
+       \r
+       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Nobody's watching me ? Let's go to sleep." << endl;\r
+       \r
+       Process::currentProcess().suspend();\r
+       \r
+       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Uuuh ? Did somebody call me ?" << endl;\r
+       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Mmmh, goodbye now." << endl; \r
+\r
+\r
+       delete this;\r
+\r
+       return 0;\r
+}
\ No newline at end of file