|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71753 - sandbox/block_ptr/libs/smart_ptr/example
From: phil_at_[hidden]
Date: 2011-05-05 19:47:30
Author: pbouchard
Date: 2011-05-05 19:47:29 EDT (Thu, 05 May 2011)
New Revision: 71753
URL: http://svn.boost.org/trac/boost/changeset/71753
Log:
* Added multithreaded test
Added:
sandbox/block_ptr/libs/smart_ptr/example/thread_test.cpp (contents, props changed)
Text files modified:
sandbox/block_ptr/libs/smart_ptr/example/Jamfile.v2 | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
Modified: sandbox/block_ptr/libs/smart_ptr/example/Jamfile.v2
==============================================================================
--- sandbox/block_ptr/libs/smart_ptr/example/Jamfile.v2 (original)
+++ sandbox/block_ptr/libs/smart_ptr/example/Jamfile.v2 2011-05-05 19:47:29 EDT (Thu, 05 May 2011)
@@ -31,4 +31,5 @@
[ run block_ptr_test1.cpp boost_thread boost_unit_test_framework ]
[ run block_ptr_test3.cpp boost_thread boost_unit_test_framework ]
[ run t100_test1.cpp boost_thread boost_regex ]
+ [ run thread_test.cpp boost_thread ]
;
Added: sandbox/block_ptr/libs/smart_ptr/example/thread_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/block_ptr/libs/smart_ptr/example/thread_test.cpp 2011-05-05 19:47:29 EDT (Thu, 05 May 2011)
@@ -0,0 +1,41 @@
+#include <iostream>
+#include <boost/thread.hpp>
+#include <boost/block_ptr.hpp>
+
+using namespace std;
+using namespace boost;
+
+
+block_ptr< pair<int, int> > p;
+
+
+void worker(int id)
+{
+ std::cout << "Worker: running" << std::endl;
+
+ for (int i = 0; i < 100000; ++ i)
+ p = make_block< pair<int, int> >(make_pair(id, i));
+
+ std::cout << "Worker: finished" << std::endl;
+}
+
+int main(int argc, char* argv[])
+{
+ std::cout << "main: startup" << std::endl;
+
+ boost::thread t0(worker, 0);
+ boost::thread t1(worker, 1);
+ //boost::thread t2(worker, 2);
+ //boost::thread t3(worker, 3);
+
+ std::cout << "main: waiting for thread" << std::endl;
+
+ t0.join();
+ t1.join();
+ //t2.join();
+ //t3.join();
+
+ std::cout << "main: done" << std::endl;
+
+ return 0;
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk