|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71967 - sandbox/block_ptr/libs/smart_ptr/example
From: phil_at_[hidden]
Date: 2011-05-16 01:20:49
Author: pbouchard
Date: 2011-05-16 01:20:48 EDT (Mon, 16 May 2011)
New Revision: 71967
URL: http://svn.boost.org/trac/boost/changeset/71967
Log:
* Now thread safe
Text files modified:
sandbox/block_ptr/libs/smart_ptr/example/thread_test.cpp | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
Modified: sandbox/block_ptr/libs/smart_ptr/example/thread_test.cpp
==============================================================================
--- sandbox/block_ptr/libs/smart_ptr/example/thread_test.cpp (original)
+++ sandbox/block_ptr/libs/smart_ptr/example/thread_test.cpp 2011-05-16 01:20:48 EDT (Mon, 16 May 2011)
@@ -1,11 +1,13 @@
#include <iostream>
#include <boost/thread.hpp>
#include <boost/block_ptr.hpp>
+//#include <boost/thread/mutex.hpp>
using namespace std;
using namespace boost;
+//mutex mutex_;
block_ptr< pair<int, int> > p;
@@ -14,7 +16,12 @@
std::cout << "Worker: running" << std::endl;
for (int i = 0; i < 100000; ++ i)
+ {
+ //mutex::scoped_lock scoped_lock(mutex_);
+ cout << id << "-" << i << ", " << flush;
p = make_block< pair<int, int> >(make_pair(id, i));
+ }
+ cout << endl;
std::cout << "Worker: finished" << std::endl;
}
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