Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Tuto_Boost / src / cpp / core / thread / 01_thread_procedure.cpp
diff --git a/WCudaMSE/Tuto_Boost/src/cpp/core/thread/01_thread_procedure.cpp b/WCudaMSE/Tuto_Boost/src/cpp/core/thread/01_thread_procedure.cpp
new file mode 100755 (executable)
index 0000000..9c7a963
--- /dev/null
@@ -0,0 +1,80 @@
+#include <iostream>\r
+//#include <thread> // include with c++11 (#CXXFLAGS+= -std=c++0x)\r
+\r
+using std::cout;\r
+using std::endl;\r
+\r
+#include <boost/thread.hpp>\r
+#include <boost/date_time.hpp>\r
+\r
+using boost::thread;\r
+using boost::posix_time::seconds;\r
+using boost::this_thread::sleep;\r
+using boost::this_thread::get_id;\r
+\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    Declaration                                     *|\r
+ \*---------------------------------------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Imported                *|\r
+ \*-------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Public                  *|\r
+ \*-------------------------------------*/\r
+\r
+void helloThread_Procedure(void);\r
+\r
+/*--------------------------------------*\\r
+ |*            Private                 *|\r
+ \*-------------------------------------*/\r
+\r
+static void runnable(void);\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    Implementation                                  *|\r
+ \*---------------------------------------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Public                  *|\r
+ \*-------------------------------------*/\r
+\r
+// http://antonym.org/2009/05/threading-with-boost---part-i-creating-threads.html\r
+\r
+void helloThread_Procedure(void)\r
+    {\r
+    cout << "\nthread : procedure : start" << endl;\r
+\r
+   thread threadRunnable(runnable);\r
+\r
+    cout << "Waiting for thread ..." << endl;\r
+\r
+    threadRunnable.join();\r
+\r
+    cout << "thread : procedure : end " << endl;\r
+    }\r
+\r
+/*--------------------------------------*\\r
+ |*            Private                 *|\r
+ \*-------------------------------------*/\r
+\r
+void runnable(void)\r
+    {\r
+    cout << "runnable : start" << endl;\r
+    cout<<"Hello from thread : id  : "<<get_id() << endl;\r
+\r
+    // Pretend to do something useful...\r
+       {\r
+       seconds workTime(3);\r
+       sleep(workTime);\r
+       }\r
+\r
+    cout << "runnable: end" << endl;\r
+    }\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    End                                             *|\r
+ \*---------------------------------------------------------------------*/\r
+\r