Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54350 - in sandbox/task: boost/task boost/task/detail libs/task/build libs/task/src
From: oliver.kowalke_at_[hidden]
Date: 2009-06-25 14:47:18


Author: olli
Date: 2009-06-25 14:47:17 EDT (Thu, 25 Jun 2009)
New Revision: 54350
URL: http://svn.boost.org/trac/boost/changeset/54350

Log:
* removed condition_variable from interrupter
* interrupt_and_wait functions form handle< R > using interrupt() and wait()

Text files modified:
   sandbox/task/boost/task/detail/interrupter.hpp | 35 ++---------------------------------
   sandbox/task/boost/task/handle.hpp | 17 +++++++++++++----
   sandbox/task/boost/task/new_thread.hpp | 8 ++++----
   sandbox/task/libs/task/build/Jamfile.v2 | 2 --
   sandbox/task/libs/task/src/interrupter.cpp | 40 +++++-----------------------------------
   5 files changed, 24 insertions(+), 78 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-06-25 14:47:17 EDT (Thu, 25 Jun 2009)
@@ -30,27 +30,18 @@
 {
 class BOOST_TASK_DECL interrupter
 {
-public:
- enum setting
- {
- wait_for,
- dont_wait
- };
-
 private:
         class impl : private noncopyable
         {
         private:
                 bool interruption_requested_;
- bool done_;
- condition_variable cond_;
                 mutex mtx_;
                 shared_ptr< thread > thrd_;
 
                 void interrupt_();
 
         public:
- impl( setting);
+ impl();
 
                 ~impl();
 
@@ -60,27 +51,13 @@
 
                 void interrupt();
 
- void interrupt_and_wait();
-
- bool interrupt_and_wait_until( system_time const& abs_time);
-
- template< typename DurationType >
- bool interrupt_and_wait_for( DurationType const& rel_time)
- {
- unique_lock< mutex > lk( mtx_);
- interrupt_();
- if ( ! done_)
- return cond_.timed_wait( lk, rel_time);
- return true;
- }
-
                 bool interruption_requested();
         };
 
         shared_ptr< impl > impl_;
 
 public:
- interrupter( setting = wait_for);
+ interrupter();
 
         void set( shared_ptr< thread > const& thrd);
 
@@ -88,14 +65,6 @@
 
         void interrupt();
 
- void interrupt_and_wait();
-
- bool interrupt_and_wait_until( system_time const& abs_time);
-
- template< typename DurationType >
- bool interrupt_and_wait_for( DurationType const& rel_time)
- { return impl_->interrupt_and_wait_for( rel_time); }
-
         bool interruption_requested();
 
         void swap( interrupter & other)

Modified: sandbox/task/boost/task/handle.hpp
==============================================================================
--- sandbox/task/boost/task/handle.hpp (original)
+++ sandbox/task/boost/task/handle.hpp 2009-06-25 14:47:17 EDT (Thu, 25 Jun 2009)
@@ -69,21 +69,30 @@
 
 public:
         handle()
- : fut_(), intr_( detail::interrupter::dont_wait)
+ : fut_(), intr_()
         {}
 
         void interrupt()
         { intr_.interrupt(); }
 
         void interrupt_and_wait()
- { intr_.interrupt_and_wait(); }
+ {
+ interrupt();
+ wait();
+ }
 
         bool interrupt_and_wait_until( system_time const& abs_time)
- { return intr_.interrupt_and_wait_until( abs_time); }
+ {
+ interrupt();
+ return wait_until( abs_time);
+ }
 
         template< typename Duration >
         bool interrupt_and_wait_for( Duration const& rel_time)
- { return intr_.interrupt_and_wait_for( rel_time); }
+ {
+ interrupt();
+ return wait_for( rel_time);
+ }
 
         bool interruption_requested()
         { return intr_.interruption_requested(); }

Modified: sandbox/task/boost/task/new_thread.hpp
==============================================================================
--- sandbox/task/boost/task/new_thread.hpp (original)
+++ sandbox/task/boost/task/new_thread.hpp 2009-06-25 14:47:17 EDT (Thu, 25 Jun 2009)
@@ -13,7 +13,6 @@
 #include <boost/thread/detail/move.hpp>
 
 #include <boost/task/detail/interrupter.hpp>
-#include <boost/task/detail/thread_callable.hpp>
 #include <boost/task/future.hpp>
 #include <boost/task/handle.hpp>
 #include <boost/task/task.hpp>
@@ -49,10 +48,11 @@
         {
                 task< R > t( t_);
                 shared_future< R > fut( t.get_future() );
- detail::interrupter intr;
- detail::thread_callable ca( boost::move( t), intr);
 
- shared_ptr< thread > thrd( new thread( ca), detail::joiner() );
+ shared_ptr< thread > thrd(
+ new thread( boost::move( t) ),
+ detail::joiner() );
+ detail::interrupter intr;
                 intr.set( thrd);
 
                 return handle< R >( fut, intr);

Modified: sandbox/task/libs/task/build/Jamfile.v2
==============================================================================
--- sandbox/task/libs/task/build/Jamfile.v2 (original)
+++ sandbox/task/libs/task/build/Jamfile.v2 2009-06-25 14:47:17 EDT (Thu, 25 Jun 2009)
@@ -41,7 +41,6 @@
         poolsize.cpp
         scanns.cpp
         semaphore_windows.cpp
- thread_callable.cpp
         watermark.cpp
         worker.cpp
         worker_group.cpp
@@ -58,7 +57,6 @@
         poolsize.cpp
         scanns.cpp
         semaphore_posix.cpp
- thread_callable.cpp
         watermark.cpp
         worker.cpp
         worker_group.cpp

Modified: sandbox/task/libs/task/src/interrupter.cpp
==============================================================================
--- sandbox/task/libs/task/src/interrupter.cpp (original)
+++ sandbox/task/libs/task/src/interrupter.cpp 2009-06-25 14:47:17 EDT (Thu, 25 Jun 2009)
@@ -22,14 +22,12 @@
         }
 }
 
-interrupter::impl::impl( setting s)
+interrupter::impl::impl()
 :
 interruption_requested_( false),
-done_( false),
-cond_(),
 mtx_(),
 thrd_()
-{ if ( s == dont_wait) reset(); }
+{}
 
 interrupter::impl::~impl()
 { reset(); }
@@ -52,9 +50,8 @@
         { this_thread::interruption_point(); }
         catch ( thread_interrupted const&)
         {}
+ thrd_.reset();
         BOOST_ASSERT( ! this_thread::interruption_requested() );
- done_ = true;
- cond_.notify_all();
 }
 
 void
@@ -64,25 +61,6 @@
         interrupt_();
 }
 
-void
-interrupter::impl::interrupt_and_wait()
-{
- unique_lock< mutex > lk( mtx_);
- interrupt_();
- while ( ! done_)
- cond_.wait( lk);
-}
-
-bool
-interrupter::impl::interrupt_and_wait_until( system_time const& abs_time)
-{
- unique_lock< mutex > lk( mtx_);
- interrupt_();
- if ( ! done_)
- return cond_.timed_wait( lk, abs_time);
- return true;
-}
-
 bool
 interrupter::impl::interruption_requested()
 {
@@ -90,8 +68,8 @@
         return interruption_requested_;
 }
 
-interrupter::interrupter( setting s)
-: impl_( new impl( s) )
+interrupter::interrupter()
+: impl_( new impl() )
 {}
 
 void
@@ -106,14 +84,6 @@
 interrupter::interrupt()
 { impl_->interrupt(); }
 
-void
-interrupter::interrupt_and_wait()
-{ impl_->interrupt_and_wait(); }
-
-bool
-interrupter::interrupt_and_wait_until( system_time const& abs_time)
-{ return impl_->interrupt_and_wait_until( abs_time); }
-
 bool
 interrupter::interruption_requested()
 { return impl_->interruption_requested(); }


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