X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=WCudaMSE%2FTuto_Boost%2Fsrc%2Fcpp%2Fcore%2Fthread%2F01_thread_procedure.cpp;fp=WCudaMSE%2FTuto_Boost%2Fsrc%2Fcpp%2Fcore%2Fthread%2F01_thread_procedure.cpp;h=9c7a963d5077871b75d5149290aa4116199ec1a7;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git 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 index 0000000..9c7a963 --- /dev/null +++ b/WCudaMSE/Tuto_Boost/src/cpp/core/thread/01_thread_procedure.cpp @@ -0,0 +1,80 @@ +#include +//#include // include with c++11 (#CXXFLAGS+= -std=c++0x) + +using std::cout; +using std::endl; + +#include +#include + +using boost::thread; +using boost::posix_time::seconds; +using boost::this_thread::sleep; +using boost::this_thread::get_id; + + +/*----------------------------------------------------------------------*\ + |* Declaration *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Imported *| + \*-------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +void helloThread_Procedure(void); + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +static void runnable(void); + +/*----------------------------------------------------------------------*\ + |* Implementation *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +// http://antonym.org/2009/05/threading-with-boost---part-i-creating-threads.html + +void helloThread_Procedure(void) + { + cout << "\nthread : procedure : start" << endl; + + thread threadRunnable(runnable); + + cout << "Waiting for thread ..." << endl; + + threadRunnable.join(); + + cout << "thread : procedure : end " << endl; + } + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +void runnable(void) + { + cout << "runnable : start" << endl; + cout<<"Hello from thread : id : "<