[Assorted-commits] SF.net SVN: assorted: [364] numa-bench/trunk/src/bthreads.cc
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-02-11 04:57:07
|
Revision: 364 http://assorted.svn.sourceforge.net/assorted/?rev=364&view=rev Author: yangzhang Date: 2008-02-10 20:57:12 -0800 (Sun, 10 Feb 2008) Log Message: ----------- added boost thread test Added Paths: ----------- numa-bench/trunk/src/bthreads.cc Added: numa-bench/trunk/src/bthreads.cc =================================================================== --- numa-bench/trunk/src/bthreads.cc (rev 0) +++ numa-bench/trunk/src/bthreads.cc 2008-02-11 04:57:12 UTC (rev 364) @@ -0,0 +1,37 @@ +#include <iostream> + +#include <boost/thread/thread.hpp> +#include <boost/bind.hpp> + +using namespace std; +using namespace boost; + +void +cnt(int i) +{ + cout << i << endl; +} + +int +main() +{ + const int n = 4; + { + thread* ts[n]; + for (int i = 0; i < n; i++) { + ts[i] = new thread(bind(&cnt, i)); + } + for (int i = 0; i < n; i++) { + ts[i]->join(); + } + } + + { + thread_group ts; + for (int i = 0; i < n; i++) { + ts.create_thread(bind(&cnt, i)); + } + ts.join_all(); + } + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |