Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52571 - in sandbox/task: boost/task boost/task/detail libs/task/src
From: oliver.kowalke_at_[hidden]
Date: 2009-04-23 15:00:25


Author: olli
Date: 2009-04-23 15:00:23 EDT (Thu, 23 Apr 2009)
New Revision: 52571
URL: http://svn.boost.org/trac/boost/changeset/52571

Log:
* reschedule until all sub-task of worker-threads are finished
* do not steal tasks from other worker-threads if rescheudled

Text files modified:
   sandbox/task/boost/task/detail/worker.hpp | 29 ++++++++++++++++++++++++-----
   sandbox/task/boost/task/handle.hpp | 36 ------------------------------------
   sandbox/task/libs/task/src/worker.cpp | 2 +-
   3 files changed, 25 insertions(+), 42 deletions(-)

Modified: sandbox/task/boost/task/detail/worker.hpp
==============================================================================
--- sandbox/task/boost/task/detail/worker.hpp (original)
+++ sandbox/task/boost/task/detail/worker.hpp 2009-04-23 15:00:23 EDT (Thu, 23 Apr 2009)
@@ -57,7 +57,7 @@
 
                 virtual void signal_shutdown_now() = 0;
 
- virtual void schedule_until( function< bool() > const&) = 0;
+ virtual void reschedule_until( function< bool() > const&) = 0;
 
                 virtual void run() = 0;
         };
@@ -143,6 +143,17 @@
                                 }
                         }
                 }
+
+ void next_callable__( callable & ca)
+ {
+ if ( ! try_take( ca) )
+ {
+ guard grd( get_pool().idle_worker_);
+ if ( shutdown_() ) return;
+ this_thread::yield();
+ this_thread::sleep( asleep_);
+ }
+ }
 
                 bool shutdown_()
                 {
@@ -230,16 +241,24 @@
                 {
                         BOOST_ASSERT( get_id() == this_thread::get_id() );
 
- schedule_until(
- bind( & impl_pool::shutdown_, this) );
+ callable ca;
+ while ( ! shutdown_() )
+ {
+ next_callable_( ca);
+ if( ! ca.empty() )
+ {
+ execute_( ca);
+ scns_ = 0;
+ }
+ }
                 }
 
- void schedule_until( function< bool() > const& pred)
+ void reschedule_until( function< bool() > const& pred)
                 {
                         callable ca;
                         while ( ! pred() )
                         {
- next_callable_( ca);
+ next_callable__( ca);
                                 if( ! ca.empty() )
                                 {
                                         execute_( ca);

Modified: sandbox/task/boost/task/handle.hpp
==============================================================================
--- sandbox/task/boost/task/handle.hpp (original)
+++ sandbox/task/boost/task/handle.hpp 2009-04-23 15:00:23 EDT (Thu, 23 Apr 2009)
@@ -118,24 +118,6 @@
                 intr_.swap( other.intr_);
                 id_.swap( other.id_);
         }
-
- bool operator==( handle< R > const& other) const
- { return id_ == other.id_; }
-
- bool operator!=( handle< R > const& other) const
- { return id_ != other.id_; }
-
- bool operator<( handle< R > const& other) const
- { return id_ < other.id_; }
-
- bool operator>( handle< R > const& other) const
- { return id_ > other.id_; }
-
- bool operator<=( handle< R > const& other) const
- { return id_ <= other.id_; }
-
- bool operator>=( handle< R > const& other) const
- { return id_ >= other.id_; }
 };
 
 template<>
@@ -236,24 +218,6 @@
                 fut_.swap( other.fut_);
                 intr_.swap( other.intr_);
         }
-
- bool operator==( handle< void > const& other) const
- { return id_ == other.id_; }
-
- bool operator!=( handle< void > const& other) const
- { return id_ != other.id_; }
-
- bool operator<( handle< void > const& other) const
- { return id_ < other.id_; }
-
- bool operator>( handle< void > const& other) const
- { return id_ > other.id_; }
-
- bool operator<=( handle< void > const& other) const
- { return id_ <= other.id_; }
-
- bool operator>=( handle< void > const& other) const
- { return id_ >= other.id_; }
 };
 
 template< typename Iterator >

Modified: sandbox/task/libs/task/src/worker.cpp
==============================================================================
--- sandbox/task/libs/task/src/worker.cpp (original)
+++ sandbox/task/libs/task/src/worker.cpp 2009-04-23 15:00:23 EDT (Thu, 23 Apr 2009)
@@ -46,7 +46,7 @@
 
 void
 worker::reschedule_until( function< bool() > const& pred)
-{ return impl_->schedule_until( pred); }
+{ return impl_->reschedule_until( pred); }
 
 void
 worker::run()


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