|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r52595 - in sandbox/task: boost/task/detail libs/task/src
From: oliver.kowalke_at_[hidden]
Date: 2009-04-25 17:18:38
Author: olli
Date: 2009-04-25 17:18:38 EDT (Sat, 25 Apr 2009)
New Revision: 52595
URL: http://svn.boost.org/trac/boost/changeset/52595
Log:
* joining thread (missing files* joining thread (missing files))
Text files modified:
sandbox/task/boost/task/detail/interrupter.hpp | 7 ++++---
sandbox/task/libs/task/src/interrupter.cpp | 17 ++++++++++-------
2 files changed, 14 insertions(+), 10 deletions(-)
Modified: sandbox/task/boost/task/detail/interrupter.hpp
==============================================================================
--- sandbox/task/boost/task/detail/interrupter.hpp (original)
+++ sandbox/task/boost/task/detail/interrupter.hpp 2009-04-25 17:18:38 EDT (Sat, 25 Apr 2009)
@@ -14,6 +14,7 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread_time.hpp>
#include <boost/utility.hpp>
+#include <boost/weak_ptr.hpp>
#include <boost/task/detail/config.hpp>
@@ -33,14 +34,14 @@
bool done_;
condition_variable cond_;
mutex mtx_;
- shared_ptr< thread > thrd_;
+ weak_ptr< thread > thrd_;
void interrupt_();
public:
impl();
- void set( shared_ptr< thread > const& thrd);
+ void set( weak_ptr< thread > const& thrd);
void reset();
@@ -66,7 +67,7 @@
public:
interrupter();
- void set( shared_ptr< thread > const& thrd);
+ void set( weak_ptr< thread > const& thrd);
void reset();
Modified: sandbox/task/libs/task/src/interrupter.cpp
==============================================================================
--- sandbox/task/libs/task/src/interrupter.cpp (original)
+++ sandbox/task/libs/task/src/interrupter.cpp 2009-04-25 17:18:38 EDT (Sat, 25 Apr 2009)
@@ -18,7 +18,8 @@
if ( ! interruption_requested_ && ! done_)
{
interruption_requested_ = true;
- if ( thrd_) thrd_->interrupt();
+ shared_ptr< thread > tmp( thrd_.lock() );
+ if ( tmp) tmp->interrupt();
}
}
@@ -32,14 +33,16 @@
{}
void
-interrupter::impl::set( shared_ptr< thread > const& thrd)
+interrupter::impl::set( weak_ptr< thread > const& thrd)
{
- BOOST_ASSERT( thrd);
unique_lock< mutex > lk( mtx_);
thrd_ = thrd;
- BOOST_ASSERT( thrd_);
+ BOOST_ASSERT( ! thrd_.expired() );
if ( interruption_requested_)
- thrd_->interrupt();
+ {
+ shared_ptr< thread > tmp( thrd_.lock() );
+ if ( tmp) tmp->interrupt();
+ }
}
void
@@ -47,7 +50,7 @@
{
unique_lock< mutex > lk( mtx_);
thrd_.reset();
- BOOST_ASSERT( ! thrd_);
+ BOOST_ASSERT( ! thrd_.expired() );
try
{ this_thread::interruption_point(); }
catch ( thread_interrupted const&)
@@ -94,7 +97,7 @@
{}
void
-interrupter::set( shared_ptr< thread > const& thrd)
+interrupter::set( weak_ptr< thread > const& thrd)
{ impl_->set( thrd); }
void
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