Difference between revisions of "CPP/Boost/ThreadsMember"
From ProgrammingExamples
< CPP
(→ThreadsMember.cxx) |
Daviddoria (Talk | contribs) |
||
Line 52: | Line 52: | ||
cmake_minimum_required(VERSION 2.6) | cmake_minimum_required(VERSION 2.6) | ||
− | Project( | + | Project(ThreadsMember) |
− | ADD_EXECUTABLE( | + | ADD_EXECUTABLE(ThreadsMember ThreadsMember.cpp) |
− | TARGET_LINK_LIBRARIES( | + | TARGET_LINK_LIBRARIES(ThreadsMember boost_thread-mt) |
</source> | </source> |
Latest revision as of 11:48, 23 January 2011
ThreadsMember.cxx
#include <iostream> #include <vector> #include <cstdlib> #include <cmath> #include <boost/thread.hpp> #include <boost/bind.hpp> using namespace std; class Test { public: void LongFunction(); }; int main(int argc, char* argv[]) { Test MyTest; boost::thread MyThread(boost::bind(&Test::LongFunction, MyTest)); cout << endl << "Stuff in main" << endl; MyThread.join(); return 0; } void Test::LongFunction() { cout << "Start LongFunction" << endl; unsigned int BigNum = 1e7; double temp; for(unsigned int i = 1; i < BigNum; i++) { temp = sin(i) / i; cout << "\r" << setw(10) << i << setw(10) << temp; cout.flush(); } cout << "End LongFunction" << endl; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) Project(ThreadsMember) ADD_EXECUTABLE(ThreadsMember ThreadsMember.cpp) TARGET_LINK_LIBRARIES(ThreadsMember boost_thread-mt)