Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81175 - in trunk/boost/thread: . detail pthread
From: vicente.botet_at_[hidden]
Date: 2012-11-04 15:37:27


Author: viboes
Date: 2012-11-04 15:37:25 EST (Sun, 04 Nov 2012)
New Revision: 81175
URL: http://svn.boost.org/trac/boost/changeset/81175

Log:
Thread: cleanup + moving lockable traits specializations to the specific files.
Text files modified:
   trunk/boost/thread/detail/thread.hpp | 1
   trunk/boost/thread/future.hpp | 62 --------------------------
   trunk/boost/thread/lock_types.hpp | 95 ++++++++++++++++++---------------------
   trunk/boost/thread/lockable_traits.hpp | 11 ++++
   trunk/boost/thread/mutex.hpp | 34 +++++++++++++
   trunk/boost/thread/pthread/thread_data.hpp | 2
   trunk/boost/thread/recursive_mutex.hpp | 45 ++++++++++++++++++
   trunk/boost/thread/shared_mutex.hpp | 22 +++++++++
   8 files changed, 153 insertions(+), 119 deletions(-)

Modified: trunk/boost/thread/detail/thread.hpp
==============================================================================
--- trunk/boost/thread/detail/thread.hpp (original)
+++ trunk/boost/thread/detail/thread.hpp 2012-11-04 15:37:25 EST (Sun, 04 Nov 2012)
@@ -243,6 +243,7 @@
         thread() BOOST_NOEXCEPT;
         ~thread()
         {
+
     #if defined BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
           if (joinable()) {
             std::terminate();

Modified: trunk/boost/thread/future.hpp
==============================================================================
--- trunk/boost/thread/future.hpp (original)
+++ trunk/boost/thread/future.hpp 2012-11-04 15:37:25 EST (Sun, 04 Nov 2012)
@@ -340,10 +340,8 @@
             }
             void make_ready()
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               boost::unique_lock<boost::mutex> lock(mutex);
               mark_finished_internal(lock);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             }
 
             void do_callback(boost::unique_lock<boost::mutex>& lock)
@@ -359,24 +357,17 @@
 
             void wait_internal(boost::unique_lock<boost::mutex> &lock, bool rethrow=true)
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               do_callback(lock);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               //if (!done) // fixme why this doesn't works?
               {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 if (is_deferred)
                 {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                   is_deferred=false;
                   execute(lock);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
-
                   //lock.unlock();
                 }
                 else
                 {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                   while(!done)
                   {
                       waiters.wait(lock);
@@ -384,14 +375,11 @@
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
                   if(rethrow && thread_was_interrupted)
                   {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                       throw boost::thread_interrupted();
                   }
 #endif
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                   if(rethrow && exception)
                   {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                       boost::rethrow_exception(exception);
                   }
                 }
@@ -399,11 +387,8 @@
             }
             void wait(bool rethrow=true)
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 boost::unique_lock<boost::mutex> lock(mutex);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 wait_internal(lock, rethrow);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             }
 
 #if defined BOOST_THREAD_USES_DATETIME
@@ -448,19 +433,13 @@
 #endif
             void mark_exceptional_finish_internal(boost::exception_ptr const& e, boost::unique_lock<boost::mutex>& lock)
             {
- //std::cout << "**************"<<__FILE__ << ":" << __LINE__ <<std::endl;
                 exception=e;
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 mark_finished_internal(lock);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             }
             void mark_exceptional_finish()
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 boost::unique_lock<boost::mutex> lock(mutex);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 mark_exceptional_finish_internal(boost::current_exception(), lock);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             }
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
             void mark_interrupted_finish()
@@ -472,23 +451,16 @@
 #endif
             void set_exception_at_thread_exit(exception_ptr e)
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               unique_lock<boost::mutex> lk(mutex);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               if (has_value(lk))
               {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                   throw_exception(promise_already_satisfied());
               }
- //std::cout << "**************"<<__FILE__ << ":" << __LINE__ <<std::endl;
               exception=e;
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             }
             bool has_value()
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 boost::lock_guard<boost::mutex> lock(mutex);
                 return done && !(exception
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
@@ -498,7 +470,6 @@
             }
             bool has_value(unique_lock<boost::mutex>& )
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 return done && !(exception
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
                     || thread_was_interrupted
@@ -660,11 +631,8 @@
 
             move_dest_type get()
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 wait();
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 return static_cast<move_dest_type>(*result);
- //return boost::move(*result); // todo check why this doesn't works (references?)
             }
 
             shared_future_get_result_type get_sh()
@@ -688,26 +656,17 @@
             }
 
 
- //void set_value_at_thread_exit(source_reference_type result_)
             void set_value_at_thread_exit(const T & result_)
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               unique_lock<boost::mutex> lk(this->mutex);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               if (this->has_value(lk))
               {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                   throw_exception(promise_already_satisfied());
               }
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               future_traits<T>::init(result,result_);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               this->is_constructed = true;
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             }
- //void set_value_at_thread_exit(rvalue_source_type result_)
             void set_value_at_thread_exit(BOOST_THREAD_RV_REF(T) result_)
             {
               unique_lock<boost::mutex> lk(this->mutex);
@@ -846,9 +805,7 @@
 
             void get()
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 this->wait();
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             }
             void get_sh()
             {
@@ -869,19 +826,13 @@
             }
             void set_value_at_thread_exit()
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               unique_lock<boost::mutex> lk(this->mutex);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               if (this->has_value(lk))
               {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                   throw_exception(promise_already_satisfied());
               }
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
              this->is_constructed = true;
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             }
         private:
             future_object(future_object const&);
@@ -1491,22 +1442,15 @@
         // retrieving the value
         move_dest_type get()
         {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             if(!this->future_)
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
                 boost::throw_exception(future_uninitialized());
             }
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
 #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             future_ptr fut_=this->future_;
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             this->future_.reset();
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             return fut_->get();
 #else
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             return this->future_->get();
 #endif
         }
@@ -2047,17 +1991,11 @@
         // setting the result with deferred notification
         void set_value_at_thread_exit()
         {
-
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
-
           if (future_.get()==0)
           {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               boost::throw_exception(promise_moved());
           }
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
           future_->set_value_at_thread_exit();
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
         }
 
         void set_exception_at_thread_exit(exception_ptr e)

Modified: trunk/boost/thread/lock_types.hpp
==============================================================================
--- trunk/boost/thread/lock_types.hpp (original)
+++ trunk/boost/thread/lock_types.hpp 2012-11-04 15:37:25 EST (Sun, 04 Nov 2012)
@@ -46,64 +46,55 @@
   }
 
 #ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES
- template<typename T>
- struct is_mutex_type<unique_lock<T> >
+ namespace sync
   {
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
-
- template<typename T>
- struct is_mutex_type<shared_lock<T> >
- {
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
-
- template<typename T>
- struct is_mutex_type<upgrade_lock<T> >
- {
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
-
- template<typename T>
- struct is_mutex_type<detail::try_lock_wrapper<T> >
- {
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
+ template<typename T>
+ struct is_basic_lockable<unique_lock<T> >
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<typename T>
+ struct is_lockable<unique_lock<T> >
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
 
- class mutex;
- class timed_mutex;
- class recursive_mutex;
- class recursive_timed_mutex;
- class shared_mutex;
+ template<typename T>
+ struct is_basic_lockable<shared_lock<T> >
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<typename T>
+ struct is_lockable<shared_lock<T> >
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
 
- template<>
- struct is_mutex_type<mutex>
- {
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
- template<>
- struct is_mutex_type<timed_mutex>
- {
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
- template<>
- struct is_mutex_type<recursive_mutex>
- {
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
- template<>
- struct is_mutex_type<recursive_timed_mutex>
- {
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
- template<>
- struct is_mutex_type<shared_mutex>
- {
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
+ template<typename T>
+ struct is_basic_lockable<upgrade_lock<T> >
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<typename T>
+ struct is_lockable<upgrade_lock<T> >
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
 
+ template<typename T>
+ struct is_basic_lockable<detail::try_lock_wrapper<T> >
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<typename T>
+ struct is_lockable<detail::try_lock_wrapper<T> >
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ }
 #endif
 
+
   template <typename Mutex>
   class unique_lock
   {

Modified: trunk/boost/thread/lockable_traits.hpp
==============================================================================
--- trunk/boost/thread/lockable_traits.hpp (original)
+++ trunk/boost/thread/lockable_traits.hpp 2012-11-04 15:37:25 EST (Sun, 04 Nov 2012)
@@ -15,6 +15,8 @@
 
 #include <boost/config/abi_prefix.hpp>
 
+// todo make use of integral_constant, true_type and false_type
+
 namespace boost
 {
   namespace sync
@@ -23,8 +25,10 @@
 #if defined(BOOST_NO_SFINAE) || \
     BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) || \
     BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
+#if ! define BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES
 #define BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES
 #endif
+#endif
 
 #ifndef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES
     namespace detail
@@ -173,13 +177,18 @@
     {
       BOOST_STATIC_CONSTANT(bool, value = false);
     };
-
     template<typename T>
     struct is_recursive_basic_lockable
     {
       BOOST_STATIC_CONSTANT(bool, value = is_basic_lockable<T>::value &&
           is_recursive_mutex_sur_parolle<T>::value);
     };
+ template<typename T>
+ struct is_recursive_lockable
+ {
+ BOOST_STATIC_CONSTANT(bool, value = is_lockable<T>::value &&
+ is_recursive_mutex_sur_parolle<T>::value);
+ };
   }
   template<typename T>
   struct is_mutex_type

Modified: trunk/boost/thread/mutex.hpp
==============================================================================
--- trunk/boost/thread/mutex.hpp (original)
+++ trunk/boost/thread/mutex.hpp 2012-11-04 15:37:25 EST (Sun, 04 Nov 2012)
@@ -3,7 +3,7 @@
 
 // mutex.hpp
 //
-// (C) Copyright 2007 Anthony Williams
+// (C) Copyright 2007 Anthony Williams
 //
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at
@@ -18,4 +18,36 @@
 #error "Boost threads unavailable on this platform"
 #endif
 
+#include <boost/thread/lockable_traits.hpp>
+
+
+namespace boost
+{
+ namespace sync
+ {
+#ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES
+ template<>
+ struct is_basic_lockable<mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<>
+ struct is_lockable<mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<>
+ struct is_basic_lockable<timed_mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<>
+ struct is_lockable<timed_mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+#endif
+ }
+}
+
 #endif

Modified: trunk/boost/thread/pthread/thread_data.hpp
==============================================================================
--- trunk/boost/thread/pthread/thread_data.hpp (original)
+++ trunk/boost/thread/pthread/thread_data.hpp 2012-11-04 15:37:25 EST (Sun, 04 Nov 2012)
@@ -146,9 +146,7 @@
 
             void make_ready_at_thread_exit(shared_ptr<future_object_base> as)
             {
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
               async_states_.push_back(as);
- //std::cout << __FILE__ << ":" << __LINE__ <<std::endl;
             }
 
         };

Modified: trunk/boost/thread/recursive_mutex.hpp
==============================================================================
--- trunk/boost/thread/recursive_mutex.hpp (original)
+++ trunk/boost/thread/recursive_mutex.hpp 2012-11-04 15:37:25 EST (Sun, 04 Nov 2012)
@@ -3,7 +3,7 @@
 
 // recursive_mutex.hpp
 //
-// (C) Copyright 2007 Anthony Williams
+// (C) Copyright 2007 Anthony Williams
 //
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at
@@ -18,4 +18,47 @@
 #error "Boost threads unavailable on this platform"
 #endif
 
+#include <boost/thread/lockable_traits.hpp>
+
+namespace boost
+{
+ namespace sync
+ {
+
+#ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES
+ template<>
+ struct is_basic_lockable<recursive_mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<>
+ struct is_lockable<recursive_mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<>
+ struct is_basic_lockable<recursive_timed_mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<>
+ struct is_lockable<recursive_timed_mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+#endif
+
+ template<>
+ struct is_recursive_mutex_sur_parolle<recursive_mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<>
+ struct is_recursive_mutex_sur_parolle<recursive_timed_mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+
+ }
+}
 #endif

Modified: trunk/boost/thread/shared_mutex.hpp
==============================================================================
--- trunk/boost/thread/shared_mutex.hpp (original)
+++ trunk/boost/thread/shared_mutex.hpp 2012-11-04 15:37:25 EST (Sun, 04 Nov 2012)
@@ -23,4 +23,26 @@
 #error "Boost threads unavailable on this platform"
 #endif
 
+#include <boost/thread/lockable_traits.hpp>
+
+namespace boost
+{
+ namespace sync
+ {
+#ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES
+ template<>
+ struct is_basic_lockable<shared_mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+ template<>
+ struct is_lockable<shared_mutex>
+ {
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+#endif
+
+ }
+}
+
 #endif


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