Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86544 - in trunk: boost/thread boost/thread/detail libs/thread/src
From: vicente.botet_at_[hidden]
Date: 2013-11-02 05:58:33


Author: viboes
Date: 2013-11-02 05:58:33 EDT (Sat, 02 Nov 2013)
New Revision: 86544
URL: http://svn.boost.org/trac/boost/changeset/86544

Log:
Thread: manage system::errc as it was an real enum class, so no implicitly convertible to an int.

Text files modified:
   trunk/boost/thread/detail/thread.hpp | 8 ++--
   trunk/boost/thread/detail/thread_group.hpp | 4 +-
   trunk/boost/thread/exceptions.hpp | 8 ++--
   trunk/boost/thread/future_error_code.hpp | 6 +-
   trunk/boost/thread/lock_types.hpp | 80 ++++++++++++++++++++--------------------
   trunk/libs/thread/src/future.cpp | 1
   6 files changed, 54 insertions(+), 53 deletions(-)

Modified: trunk/boost/thread/detail/thread.hpp
==============================================================================
--- trunk/boost/thread/detail/thread.hpp Sat Nov 2 05:56:20 2013 (r86543)
+++ trunk/boost/thread/detail/thread.hpp 2013-11-02 05:58:33 EDT (Sat, 02 Nov 2013) (r86544)
@@ -750,10 +750,10 @@
 #endif
     void thread::join() {
         if (this_thread::get_id() == get_id())
- boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself"));
+ boost::throw_exception(thread_resource_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost thread: trying joining itself"));
 
         BOOST_THREAD_VERIFY_PRECONDITION( join_noexcept(),
- thread_resource_error(system::errc::invalid_argument, "boost thread: thread not joinable")
+ thread_resource_error(static_cast<int>(system::errc::invalid_argument), "boost thread: thread not joinable")
         );
     }
 
@@ -764,7 +764,7 @@
 #endif
     {
         if (this_thread::get_id() == get_id())
- boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself"));
+ boost::throw_exception(thread_resource_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost thread: trying joining itself"));
         bool res;
         if (do_try_join_until_noexcept(timeout, res))
         {
@@ -773,7 +773,7 @@
         else
         {
           BOOST_THREAD_THROW_ELSE_RETURN(
- (thread_resource_error(system::errc::invalid_argument, "boost thread: thread not joinable")),
+ (thread_resource_error(static_cast<int>(system::errc::invalid_argument), "boost thread: thread not joinable")),
             false
           );
         }

Modified: trunk/boost/thread/detail/thread_group.hpp
==============================================================================
--- trunk/boost/thread/detail/thread_group.hpp Sat Nov 2 05:56:20 2013 (r86543)
+++ trunk/boost/thread/detail/thread_group.hpp 2013-11-02 05:58:33 EDT (Sat, 02 Nov 2013) (r86544)
@@ -85,7 +85,7 @@
             if(thrd)
             {
                 BOOST_THREAD_ASSERT_PRECONDITION( ! is_thread_in(thrd) ,
- thread_resource_error(system::errc::resource_deadlock_would_occur, "boost::thread_group: trying to add a duplicated thread")
+ thread_resource_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost::thread_group: trying to add a duplicated thread")
                 );
 
                 boost::lock_guard<shared_mutex> guard(m);
@@ -106,7 +106,7 @@
         void join_all()
         {
             BOOST_THREAD_ASSERT_PRECONDITION( ! is_this_thread_in() ,
- thread_resource_error(system::errc::resource_deadlock_would_occur, "boost::thread_group: trying joining itself")
+ thread_resource_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost::thread_group: trying joining itself")
             );
             boost::shared_lock<shared_mutex> guard(m);
 

Modified: trunk/boost/thread/exceptions.hpp
==============================================================================
--- trunk/boost/thread/exceptions.hpp Sat Nov 2 05:56:20 2013 (r86543)
+++ trunk/boost/thread/exceptions.hpp 2013-11-02 05:58:33 EDT (Sat, 02 Nov 2013) (r86544)
@@ -124,7 +124,7 @@
           typedef thread_exception base_type;
     public:
           thread_resource_error()
- : base_type(system::errc::resource_unavailable_try_again, "boost::thread_resource_error")
+ : base_type(static_cast<int>(system::errc::resource_unavailable_try_again), "boost::thread_resource_error")
           {}
 
           thread_resource_error( int ev )
@@ -152,7 +152,7 @@
           typedef thread_exception base_type;
     public:
           unsupported_thread_option()
- : base_type(system::errc::invalid_argument, "boost::unsupported_thread_option")
+ : base_type(static_cast<int>(system::errc::invalid_argument), "boost::unsupported_thread_option")
           {}
 
           unsupported_thread_option( int ev )
@@ -176,7 +176,7 @@
           typedef thread_exception base_type;
     public:
         invalid_thread_argument()
- : base_type(system::errc::invalid_argument, "boost::invalid_thread_argument")
+ : base_type(static_cast<int>(system::errc::invalid_argument), "boost::invalid_thread_argument")
         {}
 
         invalid_thread_argument( int ev )
@@ -200,7 +200,7 @@
           typedef thread_exception base_type;
     public:
           thread_permission_error()
- : base_type(system::errc::permission_denied, "boost::thread_permission_error")
+ : base_type(static_cast<int>(system::errc::permission_denied), "boost::thread_permission_error")
           {}
 
           thread_permission_error( int ev )

Modified: trunk/boost/thread/future_error_code.hpp
==============================================================================
--- trunk/boost/thread/future_error_code.hpp Sat Nov 2 05:56:20 2013 (r86543)
+++ trunk/boost/thread/future_error_code.hpp 2013-11-02 05:58:33 EDT (Sat, 02 Nov 2013) (r86544)
@@ -29,11 +29,11 @@
   namespace system
   {
     template <>
- struct BOOST_SYMBOL_VISIBLE is_error_code_enum<future_errc> : public true_type {};
+ struct BOOST_SYMBOL_VISIBLE is_error_code_enum< ::boost::future_errc> : public true_type {};
 
     #ifdef BOOST_NO_CXX11_SCOPED_ENUMS
     template <>
- struct BOOST_SYMBOL_VISIBLE is_error_code_enum<future_errc::enum_type> : public true_type { };
+ struct BOOST_SYMBOL_VISIBLE is_error_code_enum< ::boost::future_errc::enum_type> : public true_type { };
     #endif
   } // system
 
@@ -53,7 +53,7 @@
     error_condition
     make_error_condition(future_errc e) BOOST_NOEXCEPT
     {
- return error_condition(underlying_cast<int>(e), future_category());
+ return error_condition(underlying_cast<int>(e), boost::future_category());
     }
   } // system
 } // boost

Modified: trunk/boost/thread/lock_types.hpp
==============================================================================
--- trunk/boost/thread/lock_types.hpp Sat Nov 2 05:56:20 2013 (r86543)
+++ trunk/boost/thread/lock_types.hpp 2013-11-02 05:58:33 EDT (Sat, 02 Nov 2013) (r86544)
@@ -336,12 +336,12 @@
       if (m == 0)
       {
         boost::throw_exception(
- boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+ boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost unique_lock has no mutex"));
       }
       if (owns_lock())
       {
         boost::throw_exception(
- boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
+ boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex"));
       }
       m->lock();
       is_locked = true;
@@ -351,12 +351,12 @@
       if (m == 0)
       {
         boost::throw_exception(
- boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+ boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost unique_lock has no mutex"));
       }
       if (owns_lock())
       {
         boost::throw_exception(
- boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
+ boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex"));
       }
       is_locked = m->try_lock();
       return is_locked;
@@ -367,11 +367,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost unique_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex"));
       }
       is_locked=m->timed_lock(relative_time);
       return is_locked;
@@ -381,11 +381,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost unique_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex"));
       }
       is_locked=m->timed_lock(absolute_time);
       return is_locked;
@@ -394,11 +394,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost unique_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex"));
       }
       is_locked=m->timed_lock(absolute_time);
       return is_locked;
@@ -411,11 +411,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost unique_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex"));
       }
       is_locked=m->try_lock_for(rel_time);
       return is_locked;
@@ -425,11 +425,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost unique_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex"));
       }
       is_locked=m->try_lock_until(abs_time);
       return is_locked;
@@ -441,12 +441,12 @@
       if (m == 0)
       {
         boost::throw_exception(
- boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+ boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost unique_lock has no mutex"));
       }
       if (!owns_lock())
       {
         boost::throw_exception(
- boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock doesn't own the mutex"));
+ boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost unique_lock doesn't own the mutex"));
       }
       m->unlock();
       is_locked = false;
@@ -636,11 +636,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost shared_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex"));
       }
       m->lock_shared();
       is_locked=true;
@@ -649,11 +649,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost shared_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex"));
       }
       is_locked=m->try_lock_shared();
       return is_locked;
@@ -663,11 +663,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost shared_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex"));
       }
       is_locked=m->timed_lock_shared(target_time);
       return is_locked;
@@ -677,11 +677,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost shared_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex"));
       }
       is_locked=m->timed_lock_shared(target_time);
       return is_locked;
@@ -693,11 +693,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost shared_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex"));
       }
       is_locked=m->try_lock_shared_for(rel_time);
       return is_locked;
@@ -707,11 +707,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost shared_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex"));
       }
       is_locked=m->try_lock_shared_until(abs_time);
       return is_locked;
@@ -721,11 +721,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if(!owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock doesn't own the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock doesn't own the mutex"));
       }
       m->unlock_shared();
       is_locked=false;
@@ -934,12 +934,12 @@
       if (m == 0)
       {
         boost::throw_exception(
- boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if (owns_lock())
       {
         boost::throw_exception(
- boost::lock_error(system::errc::resource_deadlock_would_occur, "boost upgrade_lock owns already the mutex"));
+ boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost upgrade_lock owns already the mutex"));
       }
       m->lock_upgrade();
       is_locked = true;
@@ -949,12 +949,12 @@
       if (m == 0)
       {
         boost::throw_exception(
- boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if (owns_lock())
       {
         boost::throw_exception(
- boost::lock_error(system::errc::resource_deadlock_would_occur, "boost upgrade_lock owns already the mutex"));
+ boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost upgrade_lock owns already the mutex"));
       }
       is_locked = m->try_lock_upgrade();
       return is_locked;
@@ -964,12 +964,12 @@
       if (m == 0)
       {
         boost::throw_exception(
- boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if (!owns_lock())
       {
         boost::throw_exception(
- boost::lock_error(system::errc::operation_not_permitted, "boost upgrade_lock doesn't own the mutex"));
+ boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost upgrade_lock doesn't own the mutex"));
       }
       m->unlock_upgrade();
       is_locked = false;
@@ -980,11 +980,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost shared_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex"));
       }
       is_locked=m->try_lock_upgrade_for(rel_time);
       return is_locked;
@@ -994,11 +994,11 @@
     {
       if(m==0)
       {
- boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::operation_not_permitted), "boost shared_lock has no mutex"));
       }
       if(owns_lock())
       {
- boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost shared_lock owns already the mutex"));
+ boost::throw_exception(boost::lock_error(static_cast<int>(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex"));
       }
       is_locked=m->try_lock_upgrade_until(abs_time);
       return is_locked;

Modified: trunk/libs/thread/src/future.cpp
==============================================================================
--- trunk/libs/thread/src/future.cpp Sat Nov 2 05:56:20 2013 (r86543)
+++ trunk/libs/thread/src/future.cpp 2013-11-02 05:58:33 EDT (Sat, 02 Nov 2013) (r86544)
@@ -8,6 +8,7 @@
 
 
 #include <boost/thread/future_error_code.hpp>
+#include <string>
 
 namespace boost
 {


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