Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77687 - in trunk: boost/thread boost/thread/detail libs/thread/test/sync/futures/future libs/thread/test/sync/futures/promise
From: vicente.botet_at_[hidden]
Date: 2012-04-01 11:51:20


Author: viboes
Date: 2012-04-01 11:51:18 EDT (Sun, 01 Apr 2012)
New Revision: 77687
URL: http://svn.boost.org/trac/boost/changeset/77687

Log:
Thread: Added specific macros for futures and importing container specific into boost
Text files modified:
   trunk/boost/thread/detail/config.hpp | 47 ++++++++++++++++++++++++----
   trunk/boost/thread/detail/memory.hpp | 65 ++++++++++++++++++++++++---------------
   trunk/boost/thread/future.hpp | 27 ++++++----------
   trunk/libs/thread/test/sync/futures/future/default_pass.cpp | 22 +++++--------
   trunk/libs/thread/test/sync/futures/future/dtor_pass.cpp | 6 +-
   trunk/libs/thread/test/sync/futures/promise/alloc_ctor_pass.cpp | 6 +-
   trunk/libs/thread/test/sync/futures/promise/move_assign_pass.cpp | 12 +++---
   trunk/libs/thread/test/sync/futures/promise/move_ctor_pass.cpp | 6 +-
   8 files changed, 113 insertions(+), 78 deletions(-)

Modified: trunk/boost/thread/detail/config.hpp
==============================================================================
--- trunk/boost/thread/detail/config.hpp (original)
+++ trunk/boost/thread/detail/config.hpp 2012-04-01 11:51:18 EDT (Sun, 01 Apr 2012)
@@ -11,6 +11,17 @@
 #include <boost/config.hpp>
 #include <boost/detail/workaround.hpp>
 
+// This compiler doesn't support Boost.Chrono
+#if defined __IBMCPP__
+#define BOOST_THREAD_DONT_USE_CHRONO
+#endif
+
+// This compiler doesn't support Boost.Move
+#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100)
+#define BOOST_THREAD_DONT_USE_MOVE
+#endif
+
+// Default version is 1
 #if !defined BOOST_THREAD_VERSION
 #define BOOST_THREAD_VERSION 1
 #else
@@ -19,25 +30,23 @@
 #endif
 #endif
 
+// Uses Boost.System by default if not stated the opposite defining BOOST_THREAD_DONT_USE_SYSTEM
 #if ! defined BOOST_THREAD_DONT_USE_SYSTEM
 #define BOOST_THREAD_USES_SYSTEM
 #endif
 
-#if defined __IBMCPP__
-#define BOOST_THREAD_DONT_USE_CHRONO
-#endif
-
+// Uses Boost.Chrono by default if not stated the opposite defining BOOST_THREAD_DONT_USE_CHRONO or BOOST_THREAD_DONT_USE_SYSTEM
 #if ! defined BOOST_THREAD_DONT_USE_CHRONO && ! defined BOOST_THREAD_DONT_USE_SYSTEM
 #define BOOST_THREAD_USES_CHRONO
 #endif
 
-#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100)
-#define BOOST_THREAD_DONT_USE_MOVE
+// BOOST_THREAD_SHARED_MUTEX_GENERIC is defined if BOOST_THREAD_SHARED_MUTEX_PROVIDES_UPWARDS_CONVERSION
+#if defined BOOST_THREAD_SHARED_MUTEX_PROVIDES_UPWARDS_CONVERSION
+#define BOOST_THREAD_SHARED_MUTEX_GENERIC
 #endif
 
-//#define BOOST_THREAD_SHARED_MUTEX_PROVIDES_UPWARDS_CONVERSION
-//#define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
 
+// Don't provided by default in version 1.
 #if defined BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
 #define BOOST_THREAD_EXPLICIT_LOCK_CONVERSION explicit
 #else
@@ -45,10 +54,32 @@
 #endif
 
 
+// Uses Boost.Move by default if not stated the opposite defining BOOST_THREAD_DONT_USE_MOVE
 #if ! defined BOOST_THREAD_DONT_USE_MOVE
 #define BOOST_THREAD_USES_MOVE
 #endif
 
+#if BOOST_THREAD_VERSION==1
+#define BOOST_THREAD_PROMISE_LAZY
+#endif
+
+#if BOOST_THREAD_VERSION==2
+#define BOOST_THREAD_USES_FUTURE
+#define BOOST_THREAD_FUTURE_USES_ALLOCATORS
+#define BOOST_THREAD_SHARED_MUTEX_PROVIDES_UPWARDS_CONVERSION
+#define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
+#define BOOST_THREAD_SHARED_MUTEX_GENERIC
+#if ! defined BOOST_THREAD_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0
+#define BOOST_THREAD_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0
+#endif
+#endif
+
+// BOOST_THREAD_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0 defined by default up to Boost 1.52
+// BOOST_THREAD_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0 defined by default up to Boost 1.55
+#if ! defined BOOST_THREAD_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0
+#define BOOST_THREAD_PROVIDE_DEPRECATED_FEATURES_SINCE_V2_0_0
+#endif
+
 #if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
 # pragma warn -8008 // Condition always true/false
 # pragma warn -8080 // Identifier declared but never used

Modified: trunk/boost/thread/detail/memory.hpp
==============================================================================
--- trunk/boost/thread/detail/memory.hpp (original)
+++ trunk/boost/thread/detail/memory.hpp 2012-04-01 11:51:18 EDT (Sun, 01 Apr 2012)
@@ -17,36 +17,51 @@
 #ifndef BOOST_THREAD_DETAIL_MEMORY_HPP
 #define BOOST_THREAD_DETAIL_MEMORY_HPP
 
-
 #include <boost/container/allocator_traits.hpp>
 #include <boost/container/scoped_allocator.hpp>
+#include <boost/config.hpp>
 
-namespace boost {
-
-namespace thread_detail {
-
-template <class _Alloc>
-class allocator_destructor
+namespace boost
 {
- typedef container::allocator_traits<_Alloc> alloc_traits;
-public:
- typedef typename alloc_traits::pointer pointer;
- typedef typename alloc_traits::size_type size_type;
-private:
- _Alloc& alloc_;
- size_type s_;
-public:
- allocator_destructor(_Alloc& a, size_type s) BOOST_NOEXCEPT
- : alloc_(a), s_(s)
- {}
- void operator()(pointer p) BOOST_NOEXCEPT
+ namespace thread_detail
+ {
+ template <class _Alloc>
+ class allocator_destructor
     {
- alloc_traits::deallocate(alloc_, p, s_);
- }
-};
-
-
-} //namespace thread_detail {
+ typedef container::allocator_traits<_Alloc> alloc_traits;
+ public:
+ typedef typename alloc_traits::pointer pointer;
+ typedef typename alloc_traits::size_type size_type;
+ private:
+ _Alloc& alloc_;
+ size_type s_;
+ public:
+ allocator_destructor(_Alloc& a, size_type s)BOOST_NOEXCEPT
+ : alloc_(a), s_(s)
+ {}
+ void operator()(pointer p)BOOST_NOEXCEPT
+ {
+ alloc_traits::deallocate(alloc_, p, s_);
+ }
+ };
+ } //namespace thread_detail
+
+ typedef container::allocator_arg_t allocator_arg_t;
+ BOOST_CONSTEXPR allocator_arg_t allocator_arg = {};
+
+ template <class R>
+ class promise;
+ namespace container
+ {
+ template <class R, class Alloc>
+ struct uses_allocator<promise<R> , Alloc> : true_type
+ {
+ };
+ }
+ template <class T, class Alloc>
+ struct uses_allocator: public container::uses_allocator<T, Alloc>
+ {
+ };
 
 } // namespace boost
 

Modified: trunk/boost/thread/future.hpp
==============================================================================
--- trunk/boost/thread/future.hpp (original)
+++ trunk/boost/thread/future.hpp 2012-04-01 11:51:18 EDT (Sun, 01 Apr 2012)
@@ -40,10 +40,10 @@
 #include <boost/thread/detail/memory.hpp>
 #endif
 
-#if BOOST_THREAD_VERSION==1
-#define BOOST_THREAD_FUTURE unique_future
-#else
+#if defined BOOST_THREAD_USES_FUTURE
 #define BOOST_THREAD_FUTURE future
+#else
+#define BOOST_THREAD_FUTURE unique_future
 #endif
 
 namespace boost
@@ -1262,7 +1262,7 @@
 
         void lazy_init()
         {
-#if BOOST_THREAD_VERSION==1
+#if defined BOOST_THREAD_PROMISE_LAZY
             if(!atomic_load(&future_))
             {
                 future_ptr blank;
@@ -1274,7 +1274,7 @@
     public:
 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS
         template <class Allocator>
- explicit promise(boost::container::allocator_arg_t, Allocator a)
+ explicit promise(boost::allocator_arg_t, Allocator a)
         {
           typedef typename Allocator::template rebind<detail::future_object<R> >::other A2;
           A2 a2(a);
@@ -1285,7 +1285,7 @@
         }
 #endif
         promise():
-#if BOOST_THREAD_VERSION==1
+#if defined BOOST_THREAD_PROMISE_LAZY
             future_(),
 #else
             future_(new detail::future_object<R>()),
@@ -1309,22 +1309,15 @@
         // Assignment
 #ifndef BOOST_NO_RVALUE_REFERENCES
         promise(promise && rhs) BOOST_NOEXCEPT:
-//#if ! BOOST_THREAD_VERSION==1
- // future_(rhs.future_),
-//#endif
             future_obtained(rhs.future_obtained)
         {
-//#if BOOST_THREAD_VERSION==1
             future_.swap(rhs.future_);
-//#else
- // we need to release the future as shared_ptr doesn't implements move semantics
             rhs.future_.reset();
-//#endif
             rhs.future_obtained=false;
         }
         promise & operator=(promise&& rhs) BOOST_NOEXCEPT
         {
-#if BOOST_THREAD_VERSION==1
+#if defined BOOST_THREAD_PROMISE_LAZY
             future_.swap(rhs.future_);
             future_obtained=rhs.future_obtained;
             rhs.future_.reset();
@@ -1476,7 +1469,7 @@
 
         void lazy_init()
         {
-#if BOOST_THREAD_VERSION==1
+#if defined BOOST_THREAD_PROMISE_LAZY
             if(!atomic_load(&future_))
             {
                 future_ptr blank;
@@ -1487,7 +1480,7 @@
     public:
 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS
         template <class Allocator>
- explicit promise(boost::container::allocator_arg_t, Allocator a)
+ explicit promise(boost::allocator_arg_t, Allocator a)
         {
           typedef typename Allocator::template rebind<detail::future_object<void> >::other A2;
           A2 a2(a);
@@ -1498,7 +1491,7 @@
         }
 #endif
         promise():
-#if BOOST_THREAD_VERSION==1
+#if defined BOOST_THREAD_PROMISE_LAZY
             future_(),
 #else
             future_(new detail::future_object<void>),

Modified: trunk/libs/thread/test/sync/futures/future/default_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/future/default_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/future/default_pass.cpp 2012-04-01 11:51:18 EDT (Sun, 01 Apr 2012)
@@ -14,9 +14,9 @@
 
 // <boost/thread/future.hpp>
 
-// class promise<R>
+// class future<R>
 
-// promise();
+// future();
 
 #define BOOST_THREAD_VERSION 2
 
@@ -27,23 +27,19 @@
 {
 
   {
- boost::promise<int> p;
- boost::future<int> f = p.get_future();
- BOOST_TEST(f.valid());
+ boost::future<int> f;
+ BOOST_TEST(!f.valid());
   }
   {
- boost::promise<int&> p;
- boost::future<int&> f = p.get_future();
- BOOST_TEST(f.valid());
+ boost::future<int&> f;
+ BOOST_TEST(!f.valid());
   }
   {
- boost::promise<void> p;
- std::cout << __LINE__ << std::endl;
- boost::future<void> f = p.get_future();
- std::cout << __LINE__ << std::endl;
- BOOST_TEST(f.valid());
+ boost::future<void> f;
+ BOOST_TEST(!f.valid());
   }
 
+
   return boost::report_errors();
 }
 

Modified: trunk/libs/thread/test/sync/futures/future/dtor_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/future/dtor_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/future/dtor_pass.cpp 2012-04-01 11:51:18 EDT (Sun, 01 Apr 2012)
@@ -35,7 +35,7 @@
       typedef int T;
       boost::future<T> f;
       {
- boost::promise<T> p(boost::container::allocator_arg, test_allocator<T>());
+ boost::promise<T> p(boost::allocator_arg, test_allocator<T>());
           BOOST_TEST(test_alloc_base::count == 1);
           f = p.get_future();
           BOOST_TEST(test_alloc_base::count == 1);
@@ -49,7 +49,7 @@
       typedef int& T;
       boost::future<T> f;
       {
- boost::promise<T> p(boost::container::allocator_arg, test_allocator<int>());
+ boost::promise<T> p(boost::allocator_arg, test_allocator<int>());
           BOOST_TEST(test_alloc_base::count == 1);
           f = p.get_future();
           BOOST_TEST(test_alloc_base::count == 1);
@@ -63,7 +63,7 @@
       typedef void T;
       boost::future<T> f;
       {
- boost::promise<T> p(boost::container::allocator_arg, test_allocator<T>());
+ boost::promise<T> p(boost::allocator_arg, test_allocator<T>());
           BOOST_TEST(test_alloc_base::count == 1);
           f = p.get_future();
           BOOST_TEST(test_alloc_base::count == 1);

Modified: trunk/libs/thread/test/sync/futures/promise/alloc_ctor_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/promise/alloc_ctor_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/promise/alloc_ctor_pass.cpp 2012-04-01 11:51:18 EDT (Sun, 01 Apr 2012)
@@ -29,7 +29,7 @@
 {
   BOOST_TEST(test_alloc_base::count == 0);
   {
- boost::promise<int> p(boost::container::allocator_arg, test_allocator<int>());
+ boost::promise<int> p(boost::allocator_arg, test_allocator<int>());
       BOOST_TEST(test_alloc_base::count == 1);
       boost::future<int> f = p.get_future();
       BOOST_TEST(test_alloc_base::count == 1);
@@ -37,7 +37,7 @@
   }
   BOOST_TEST(test_alloc_base::count == 0);
   {
- boost::promise<int&> p(boost::container::allocator_arg, test_allocator<int>());
+ boost::promise<int&> p(boost::allocator_arg, test_allocator<int>());
       BOOST_TEST(test_alloc_base::count == 1);
       boost::future<int&> f = p.get_future();
       BOOST_TEST(test_alloc_base::count == 1);
@@ -45,7 +45,7 @@
   }
   BOOST_TEST(test_alloc_base::count == 0);
   {
- boost::promise<void> p(boost::container::allocator_arg, test_allocator<void>());
+ boost::promise<void> p(boost::allocator_arg, test_allocator<void>());
       BOOST_TEST(test_alloc_base::count == 1);
       boost::future<void> f = p.get_future();
       BOOST_TEST(test_alloc_base::count == 1);

Modified: trunk/libs/thread/test/sync/futures/promise/move_assign_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/promise/move_assign_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/promise/move_assign_pass.cpp 2012-04-01 11:51:18 EDT (Sun, 01 Apr 2012)
@@ -35,8 +35,8 @@
 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS
   BOOST_TEST(test_alloc_base::count == 0);
   {
- boost::promise<int> p0(boost::container::allocator_arg, test_allocator<int>());
- boost::promise<int> p(boost::container::allocator_arg, test_allocator<int>());
+ boost::promise<int> p0(boost::allocator_arg, test_allocator<int>());
+ boost::promise<int> p(boost::allocator_arg, test_allocator<int>());
     BOOST_TEST(test_alloc_base::count == 2);
     p = boost::move(p0);
     BOOST_TEST(test_alloc_base::count == 1);
@@ -57,8 +57,8 @@
   BOOST_TEST(test_alloc_base::count == 0);
 
   {
- boost::promise<int&> p0(boost::container::allocator_arg, test_allocator<int>());
- boost::promise<int&> p(boost::container::allocator_arg, test_allocator<int>());
+ boost::promise<int&> p0(boost::allocator_arg, test_allocator<int>());
+ boost::promise<int&> p(boost::allocator_arg, test_allocator<int>());
     BOOST_TEST(test_alloc_base::count == 2);
     p = boost::move(p0);
     BOOST_TEST(test_alloc_base::count == 1);
@@ -78,8 +78,8 @@
   }
   BOOST_TEST(test_alloc_base::count == 0);
   {
- boost::promise<void> p0(boost::container::allocator_arg, test_allocator<void>());
- boost::promise<void> p(boost::container::allocator_arg, test_allocator<void>());
+ boost::promise<void> p0(boost::allocator_arg, test_allocator<void>());
+ boost::promise<void> p(boost::allocator_arg, test_allocator<void>());
     BOOST_TEST(test_alloc_base::count == 2);
     p = boost::move(p0);
     BOOST_TEST(test_alloc_base::count == 1);

Modified: trunk/libs/thread/test/sync/futures/promise/move_ctor_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/promise/move_ctor_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/promise/move_ctor_pass.cpp 2012-04-01 11:51:18 EDT (Sun, 01 Apr 2012)
@@ -34,7 +34,7 @@
 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS
   BOOST_TEST(test_alloc_base::count == 0);
   {
- boost::promise<int> p0(boost::container::allocator_arg, test_allocator<int>());
+ boost::promise<int> p0(boost::allocator_arg, test_allocator<int>());
     boost::promise<int> p(boost::move(p0));
     BOOST_TEST(test_alloc_base::count == 1);
     std::cout << __LINE__ << std::endl;
@@ -58,7 +58,7 @@
   std::cout << __LINE__ << std::endl;
   BOOST_TEST(test_alloc_base::count == 0);
   {
- boost::promise<int&> p0(boost::container::allocator_arg, test_allocator<int>());
+ boost::promise<int&> p0(boost::allocator_arg, test_allocator<int>());
     boost::promise<int&> p(boost::move(p0));
     BOOST_TEST(test_alloc_base::count == 1);
     boost::future<int&> f = p.get_future();
@@ -77,7 +77,7 @@
   }
   BOOST_TEST(test_alloc_base::count == 0);
   {
- boost::promise<void> p0(boost::container::allocator_arg, test_allocator<void>());
+ boost::promise<void> p0(boost::allocator_arg, test_allocator<void>());
     boost::promise<void> p(boost::move(p0));
     BOOST_TEST(test_alloc_base::count == 1);
     boost::future<void> f = p.get_future();


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