Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54465 - in sandbox/task: boost/task boost/task/detail libs/task/src
From: oliver.kowalke_at_[hidden]
Date: 2009-06-28 08:14:57


Author: olli
Date: 2009-06-28 08:14:55 EDT (Sun, 28 Jun 2009)
New Revision: 54465
URL: http://svn.boost.org/trac/boost/changeset/54465

Log:
* refactoring

Text files modified:
   sandbox/task/boost/task/detail/callable.hpp | 36 ++++++++++--------------------------
   sandbox/task/boost/task/detail/interrupter.hpp | 11 +++++++++++
   sandbox/task/boost/task/detail/worker.hpp | 2 +-
   sandbox/task/boost/task/detail/worker_group.hpp | 4 ++--
   sandbox/task/boost/task/handle.hpp | 6 ++++++
   sandbox/task/boost/task/new_thread.hpp | 8 +++++---
   sandbox/task/boost/task/own_thread.hpp | 4 +---
   sandbox/task/libs/task/src/callable.cpp | 9 +++------
   sandbox/task/libs/task/src/interrupter.cpp | 7 +++++++
   9 files changed, 46 insertions(+), 41 deletions(-)

Modified: sandbox/task/boost/task/detail/callable.hpp
==============================================================================
--- sandbox/task/boost/task/detail/callable.hpp (original)
+++ sandbox/task/boost/task/detail/callable.hpp 2009-06-28 08:14:55 EDT (Sun, 28 Jun 2009)
@@ -10,7 +10,6 @@
 #include <boost/config.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/thread.hpp>
-#include <boost/utility.hpp>
 
 #include <boost/task/detail/config.hpp>
 #include <boost/task/detail/interrupter.hpp>
@@ -30,60 +29,43 @@
 class BOOST_TASK_DECL callable
 {
 private:
- friend class scoped_guard;
-
         struct impl
         {
                 virtual ~impl() {}
                 virtual void run() = 0;
- virtual void set( shared_ptr< thread > &) = 0;
- virtual void reset() = 0;
+ virtual interrupter & get_interrupter() = 0;
         };
 
         template< typename R >
         class impl_wrapper : public impl
         {
         private:
- task< R > t_;
- detail::interrupter i_;
+ task< R > t_;
+ interrupter i_;
 
         public:
                 impl_wrapper(
                         task< R > t,
- detail::interrupter const& i)
+ interrupter const& i)
                 : t_( boost::move( t) ), i_( i)
                 {}
 
                 void run()
                 { t_(); }
-
- void set( shared_ptr< thread > & thrd)
- { i_.set( thrd); }
-
- void reset()
- { i_.reset(); }
+
+ interrupter & get_interrupter()
+ { return i_; }
         };
 
         shared_ptr< impl > impl_;
 
 public:
- class scoped_guard : public noncopyable
- {
- private:
- callable & ca_;
-
- public:
- scoped_guard( callable &, shared_ptr< thread > &);
-
- ~scoped_guard();
- };
-
         callable();
 
         template< typename R >
         callable(
                 task< R > t,
- detail::interrupter const& i)
+ interrupter const& i)
         : impl_( new impl_wrapper< R >( boost::move( t), i) )
         {}
 
@@ -92,6 +74,8 @@
         bool empty() const;
 
         void clear();
+
+ interrupter & get_interrupter();
 };
 }}}
 

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-28 08:14:55 EDT (Sun, 28 Jun 2009)
@@ -59,6 +59,17 @@
         shared_ptr< impl > impl_;
 
 public:
+ class scoped_guard : public noncopyable
+ {
+ private:
+ interrupter & intr_;
+
+ public:
+ scoped_guard( interrupter &, shared_ptr< thread > &);
+
+ ~scoped_guard();
+ };
+
         interrupter();
 
         void set( shared_ptr< thread > const& thrd);

Modified: sandbox/task/boost/task/detail/worker.hpp
==============================================================================
--- sandbox/task/boost/task/detail/worker.hpp (original)
+++ sandbox/task/boost/task/detail/worker.hpp 2009-06-28 08:14:55 EDT (Sun, 28 Jun 2009)
@@ -107,7 +107,7 @@
                         BOOST_ASSERT( ! ca.empty() );
                         guard grd( get_pool().active_worker_);
                         {
- callable::scoped_guard lk( ca, thrd_);
+ interrupter::scoped_guard lk( ca.get_interrupter(), thrd_);
                                 ca();
                         }
                         ca.clear();

Modified: sandbox/task/boost/task/detail/worker_group.hpp
==============================================================================
--- sandbox/task/boost/task/detail/worker_group.hpp (original)
+++ sandbox/task/boost/task/detail/worker_group.hpp 2009-06-28 08:14:55 EDT (Sun, 28 Jun 2009)
@@ -65,12 +65,12 @@
 
         ~worker_group();
 
- const worker operator[]( std::size_t pos) const;
-
         std::size_t size() const;
 
         bool empty() const;
 
+ const worker operator[]( std::size_t pos) const;
+
         const iterator begin();
         const const_iterator begin() const;
 

Modified: sandbox/task/boost/task/handle.hpp
==============================================================================
--- sandbox/task/boost/task/handle.hpp (original)
+++ sandbox/task/boost/task/handle.hpp 2009-06-28 08:14:55 EDT (Sun, 28 Jun 2009)
@@ -59,6 +59,12 @@
         shared_future< R > fut_;
         detail::interrupter intr_;
 
+ handle( shared_future< R > fut)
+ :
+ fut_( fut),
+ intr_()
+ {}
+
         handle(
                 shared_future< R > fut,
                 detail::interrupter const& intr)

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-28 08:14:55 EDT (Sun, 28 Jun 2009)
@@ -47,9 +47,11 @@
 
                 detail::interrupter intr;
                 shared_ptr< thread > thrd(
- new thread(
- detail::callable( boost::move( t), intr) ),
- detail::joiner() );
+ new thread(
+ detail::callable(
+ boost::move( t),
+ intr) ),
+ detail::joiner() );
                 intr.set( thrd);
 
                 return handle< R >( fut, intr);

Modified: sandbox/task/boost/task/own_thread.hpp
==============================================================================
--- sandbox/task/boost/task/own_thread.hpp (original)
+++ sandbox/task/boost/task/own_thread.hpp 2009-06-28 08:14:55 EDT (Sun, 28 Jun 2009)
@@ -24,10 +24,8 @@
         handle< R > operator()( task< R > t)
         {
                 shared_future< R > fut( t.get_future() );
- detail::interrupter intr;
- intr.reset();
                 t();
- return handle< R >( fut, intr);
+ return handle< R >( fut);
         }
 };
 } }

Modified: sandbox/task/libs/task/src/callable.cpp
==============================================================================
--- sandbox/task/libs/task/src/callable.cpp (original)
+++ sandbox/task/libs/task/src/callable.cpp 2009-06-28 08:14:55 EDT (Sun, 28 Jun 2009)
@@ -26,11 +26,8 @@
 callable::clear()
 { impl_.reset(); }
 
-callable::scoped_guard::scoped_guard( callable & ca, shared_ptr< thread > & thrd)
-: ca_( ca)
-{ ca_.impl_->set( thrd); }
-
-callable::scoped_guard::~scoped_guard()
-{ ca_.impl_->reset(); }
+interrupter &
+callable::get_interrupter()
+{ return impl_->get_interrupter(); }
 } } }
 

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-28 08:14:55 EDT (Sun, 28 Jun 2009)
@@ -96,6 +96,13 @@
 bool
 interrupter::interruption_requested()
 { return impl_->interruption_requested(); }
+
+interrupter::scoped_guard::scoped_guard( interrupter & intr, shared_ptr< thread > & thrd)
+: intr_( intr)
+{ intr_.set( thrd); }
+
+interrupter::scoped_guard::~scoped_guard()
+{ intr_.reset(); }
 }
 } }
 


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