Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85200 - in branches/release: boost/thread boost/thread/detail boost/thread/pthread boost/thread/v2 boost/thread/win32 libs/thread libs/thread/doc libs/thread/example libs/thread/test libs/thread/test/sync/futures/async libs/thread/test/sync/futures/future libs/thread/test/sync/futures/packaged_task libs/thread/test/sync/futures/promise libs/thread/test/sync/futures/shared_future libs/thread/test/sync/mutual_exclusion/sync_bounded_queue libs/thread/test/sync/mutual_exclusion/sync_queue libs/thread/test/threads/this_thread/sleep_for
From: vicente.botet_at_[hidden]
Date: 2013-08-03 12:04:40


Author: viboes
Date: 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013)
New Revision: 85200
URL: http://svn.boost.org/trac/boost/changeset/85200

Log:
Thread: merge from trunk last updates since 1.54.

Added:
   branches/release/libs/thread/example/future_fallback_to.cpp
      - copied unchanged from r84750, trunk/libs/thread/example/future_fallback_to.cpp
   branches/release/libs/thread/example/future_unwrap.cpp
      - copied unchanged from r84750, trunk/libs/thread/example/future_unwrap.cpp
   branches/release/libs/thread/test/sync/futures/future/get_or_pass.cpp
      - copied unchanged from r84750, trunk/libs/thread/test/sync/futures/future/get_or_pass.cpp
   branches/release/libs/thread/test/sync/futures/shared_future/then_pass.cpp
      - copied, changed from r84588, trunk/libs/thread/test/sync/futures/shared_future/then_pass.cpp
   branches/release/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/
      - copied from r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/
   branches/release/libs/thread/test/sync/mutual_exclusion/sync_queue/
      - copied from r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_queue/
   branches/release/libs/thread/test/test_8674.cpp
      - copied unchanged from r84708, trunk/libs/thread/test/test_8674.cpp
   branches/release/libs/thread/test/test_barrier_size_fct.cpp
      - copied, changed from r84832, trunk/libs/thread/test/test_barrier_size_fct.cpp
   branches/release/libs/thread/test/test_barrier_void_fct.cpp
      - copied unchanged from r84832, trunk/libs/thread/test/test_barrier_void_fct.cpp
Replaced:
   branches/release/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/multi_thread_pass.cpp
      - copied unchanged from r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/multi_thread_pass.cpp
   branches/release/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/single_thread_pass.cpp
      - copied unchanged from r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/single_thread_pass.cpp
   branches/release/libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp
      - copied unchanged from r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp
   branches/release/libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp
      - copied unchanged from r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp
Properties modified:
   branches/release/boost/thread/ (props changed)
   branches/release/libs/thread/ (props changed)
Text files modified:
   branches/release/boost/thread/barrier.hpp | 215 ++++
   branches/release/boost/thread/detail/config.hpp | 5
   branches/release/boost/thread/detail/counter.hpp | 21
   branches/release/boost/thread/detail/is_convertible.hpp | 7
   branches/release/boost/thread/detail/memory.hpp | 7
   branches/release/boost/thread/future.hpp | 1626 +++++++++++++++++++++++----------------
   branches/release/boost/thread/latch.hpp | 51
   branches/release/boost/thread/pthread/thread_data.hpp | 6
   branches/release/boost/thread/sync_bounded_queue.hpp | 96 +-
   branches/release/boost/thread/sync_queue.hpp | 79 -
   branches/release/boost/thread/testable_mutex.hpp | 4
   branches/release/boost/thread/v2/shared_mutex.hpp | 12
   branches/release/boost/thread/win32/thread_data.hpp | 6
   branches/release/boost/thread/win32/thread_primitives.hpp | 2
   branches/release/libs/thread/doc/barrier.qbk | 69 +
   branches/release/libs/thread/doc/changes.qbk | 22
   branches/release/libs/thread/doc/future_ref.qbk | 640 +++++++++++----
   branches/release/libs/thread/doc/futures.qbk | 47
   branches/release/libs/thread/doc/latch.qbk | 61 +
   branches/release/libs/thread/doc/sync_streams.qbk | 19
   branches/release/libs/thread/doc/synchronized_value.qbk | 2
   branches/release/libs/thread/doc/thread.qbk | 6
   branches/release/libs/thread/example/future_fallback_to.cpp | 78 +
   branches/release/libs/thread/example/future_then.cpp | 41
   branches/release/libs/thread/example/future_unwrap.cpp | 59 +
   branches/release/libs/thread/example/lambda_future.cpp | 2
   branches/release/libs/thread/example/make_future.cpp | 21
   branches/release/libs/thread/example/perf_condition_variable.cpp | 4
   branches/release/libs/thread/example/perf_shared_mutex.cpp | 4
   branches/release/libs/thread/example/tennis.cpp | 3
   branches/release/libs/thread/test/Jamfile.v2 | 39
   branches/release/libs/thread/test/sync/futures/async/async_pass.cpp | 661 +++++++++------
   branches/release/libs/thread/test/sync/futures/future/get_or_pass.cpp | 182 ++++
   branches/release/libs/thread/test/sync/futures/future/then_pass.cpp | 37
   branches/release/libs/thread/test/sync/futures/packaged_task/func_ctor_pass.cpp | 95 ++
   branches/release/libs/thread/test/sync/futures/promise/default_pass.cpp | 2
   branches/release/libs/thread/test/sync/futures/shared_future/then_pass.cpp | 35
   branches/release/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/multi_thread_pass.cpp | 252 ++++++
   branches/release/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/single_thread_pass.cpp | 226 +++++
   branches/release/libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp | 185 ++++
   branches/release/libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp | 203 ++++
   branches/release/libs/thread/test/test_7160.cpp | 29
   branches/release/libs/thread/test/test_8596.cpp | 15
   branches/release/libs/thread/test/test_8674.cpp | 43 +
   branches/release/libs/thread/test/test_barrier.cpp | 2
   branches/release/libs/thread/test/test_barrier_size_fct.cpp | 2
   branches/release/libs/thread/test/test_barrier_void_fct.cpp | 67 +
   branches/release/libs/thread/test/threads/this_thread/sleep_for/sleep_for_pass.cpp | 1
   48 files changed, 3886 insertions(+), 1405 deletions(-)

Modified: branches/release/boost/thread/barrier.hpp
==============================================================================
--- branches/release/boost/thread/barrier.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/barrier.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -17,51 +17,196 @@
 #include <boost/thread/condition_variable.hpp>
 #include <string>
 #include <stdexcept>
+#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
+#include <boost/function.hpp>
+#else
+#include <functional>
+#endif
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/is_void.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/utility/result_of.hpp>
 
 #include <boost/config/abi_prefix.hpp>
 
 namespace boost
 {
+ namespace thread_detail
+ {
+#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
+ typedef function<void()> void_completion_function;
+ typedef function<size_t()> size_completion_function;
+#else
+ typedef std::function<void()> void_completion_function;
+ typedef std::function<size_t()> size_completion_function;
+#endif
 
- class barrier
+ struct default_barrier_reseter
     {
- public:
- BOOST_THREAD_NO_COPYABLE( barrier )
+ unsigned int size_;
+ default_barrier_reseter(unsigned int size) :
+ size_(size)
+ {
+ }
+ unsigned int operator()()
+ {
+ return size_;
+ }
+ };
 
- barrier(unsigned int count)
- : m_threshold(count), m_count(count), m_generation(0)
- {
- if (count == 0)
- boost::throw_exception(thread_exception(system::errc::invalid_argument, "barrier constructor: count cannot be zero."));
- }
-
- bool wait()
- {
- boost::unique_lock<boost::mutex> lock(m_mutex);
- unsigned int gen = m_generation;
-
- if (--m_count == 0)
- {
- m_generation++;
- m_count = m_threshold;
- m_cond.notify_all();
- return true;
- }
-
- while (gen == m_generation)
- m_cond.wait(lock);
- return false;
- }
-
- private:
- mutex m_mutex;
- condition_variable m_cond;
- unsigned int m_threshold;
- unsigned int m_count;
- unsigned int m_generation;
+ struct void_functor_barrier_reseter
+ {
+ unsigned int size_;
+ void_completion_function fct_;template <typename F>
+#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
+ void_functor_barrier_reseter(unsigned int size, BOOST_THREAD_RV_REF(F) funct)
+ : size_(size), fct_(boost::move(funct))
+ {}
+#else
+ void_functor_barrier_reseter(unsigned int size, F funct)
+ : size_(size), fct_(funct)
+ {}
+#endif
+ unsigned int operator()()
+ {
+ fct_();
+ return size_;
+ }
+ };
+ struct void_fct_ptr_barrier_reseter
+ {
+ unsigned int size_;
+ void(*fct_)();
+ void_fct_ptr_barrier_reseter(unsigned int size, void(*funct)()) :
+ size_(size), fct_(funct)
+ {
+ }
+ unsigned int operator()()
+ {
+ fct_();
+ return size_;
+ }
     };
+ }
+ class barrier
+ {
+ static inline unsigned int check(unsigned int count)
+ {
+ if (count == 0) boost::throw_exception(
+ thread_exception(system::errc::invalid_argument, "barrier constructor: count cannot be zero."));
+ return count;
+ }
+ struct dummy
+ {
+ };
+
+ public:
+ BOOST_THREAD_NO_COPYABLE( barrier)
+
+ explicit barrier(unsigned int count) :
+ m_count(check(count)), m_generation(0), fct_(thread_detail::default_barrier_reseter(count))
+ {
+ }
+
+ template <typename F>
+ barrier(
+ unsigned int count,
+#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
+ BOOST_THREAD_RV_REF(F) funct,
+#else
+ F funct,
+#endif
+ typename enable_if<
+ typename is_void<typename result_of<F>::type>::type, dummy*
+ >::type=0
+ )
+ : m_count(check(count)),
+ m_generation(0),
+ fct_(thread_detail::void_functor_barrier_reseter(count,
+#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
+ boost::move(funct)
+#else
+ funct
+#endif
+ )
+ )
+ {
+ }
+
+ template <typename F>
+ barrier(
+ unsigned int count,
+#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
+ BOOST_THREAD_RV_REF(F) funct,
+#else
+ F funct,
+#endif
+ typename enable_if<
+ typename is_same<typename result_of<F>::type, unsigned int>::type, dummy*
+ >::type=0
+ )
+ : m_count(check(count)),
+ m_generation(0),
+ fct_(
+#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
+ boost::move(funct)
+#else
+ funct
+#endif
+ )
+ {
+ }
+
+ barrier(unsigned int count, void(*funct)()) :
+ m_count(check(count)), m_generation(0),
+ fct_(funct
+ ? thread_detail::size_completion_function(thread_detail::void_fct_ptr_barrier_reseter(count, funct))
+ : thread_detail::size_completion_function(thread_detail::default_barrier_reseter(count))
+ )
+ {
+ }
+ barrier(unsigned int count, unsigned int(*funct)()) :
+ m_count(check(count)), m_generation(0),
+ fct_(funct
+ ? thread_detail::size_completion_function(funct)
+ : thread_detail::size_completion_function(thread_detail::default_barrier_reseter(count))
+ )
+ {
+ }
+
+ bool wait()
+ {
+ boost::unique_lock < boost::mutex > lock(m_mutex);
+ unsigned int gen = m_generation;
+
+ if (--m_count == 0)
+ {
+ m_generation++;
+ m_count = static_cast<unsigned int>(fct_());
+ BOOST_ASSERT(m_count != 0);
+ m_cond.notify_all();
+ return true;
+ }
+
+ while (gen == m_generation)
+ m_cond.wait(lock);
+ return false;
+ }
+
+ void count_down_and_wait()
+ {
+ wait();
+ }
+
+ private:
+ mutex m_mutex;
+ condition_variable m_cond;
+ unsigned int m_count;
+ unsigned int m_generation;
+ thread_detail::size_completion_function fct_;
+ };
 
-} // namespace boost
+} // namespace boost
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: branches/release/boost/thread/detail/config.hpp
==============================================================================
--- branches/release/boost/thread/detail/config.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/detail/config.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -264,6 +264,11 @@
 #define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
 #endif
 
+#if ! defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP \
+ && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_UNWRAP
+#define BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
+#endif
+
 // FUTURE_INVALID_AFTER_GET
 #if ! defined BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET \
  && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_INVALID_AFTER_GET

Modified: branches/release/boost/thread/detail/counter.hpp
==============================================================================
--- branches/release/boost/thread/detail/counter.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/detail/counter.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -75,15 +75,28 @@
     };
     struct counter_is_not_zero
     {
- counter_is_not_zero(const counter& count) : count_(count) {}
+ counter_is_not_zero(counter const& count) : count_(count) {}
       bool operator()() const { return count_ != 0; }
- const counter& count_;
+ counter const& count_;
     };
     struct counter_is_zero
     {
- counter_is_zero(const counter& count) : count_(count) {}
+ counter_is_zero(counter const& count) : count_(count) {}
       bool operator()() const { return count_ == 0; }
- const counter& count_;
+ counter const& count_;
+ };
+ struct is_zero
+ {
+ is_zero(std::size_t& count) : count_(count) {}
+ bool operator()() const { return count_ == 0; }
+ std::size_t& count_;
+ };
+ struct not_equal
+ {
+ not_equal(std::size_t& x, std::size_t& y) : x_(x), y_(y) {}
+ bool operator()() const { return x_ != y_; }
+ std::size_t& x_;
+ std::size_t& y_;
     };
   }
 } // namespace boost

Modified: branches/release/boost/thread/detail/is_convertible.hpp
==============================================================================
--- branches/release/boost/thread/detail/is_convertible.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/detail/is_convertible.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -1,8 +1,9 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright 2011-2012 Vicente J. Botet Escriba
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+// Copyright (C) 2011-2013 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 //
 // See http://www.boost.org/libs/thread for documentation.
 //

Modified: branches/release/boost/thread/detail/memory.hpp
==============================================================================
--- branches/release/boost/thread/detail/memory.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/detail/memory.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -1,8 +1,9 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright 2011-2012 Vicente J. Botet Escriba
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+// Copyright (C) 2011-2013 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 //
 // See http://www.boost.org/libs/thread for documentation.
 //

Modified: branches/release/boost/thread/future.hpp
==============================================================================
--- branches/release/boost/thread/future.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/future.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -32,6 +32,7 @@
 #include <boost/thread/detail/is_convertible.hpp>
 #include <boost/type_traits/remove_reference.hpp>
 #include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/is_void.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/config.hpp>
 #include <boost/throw_exception.hpp>
@@ -145,23 +146,23 @@
         {}
     };
 
- class BOOST_SYMBOL_VISIBLE task_moved:
- public future_error
- {
- public:
- task_moved():
- future_error(system::make_error_code(future_errc::no_state))
- {}
- };
+ class BOOST_SYMBOL_VISIBLE task_moved:
+ public future_error
+ {
+ public:
+ task_moved():
+ future_error(system::make_error_code(future_errc::no_state))
+ {}
+ };
 
- class promise_moved:
- public future_error
- {
- public:
- promise_moved():
- future_error(system::make_error_code(future_errc::no_state))
- {}
- };
+ class promise_moved:
+ public future_error
+ {
+ public:
+ promise_moved():
+ future_error(system::make_error_code(future_errc::no_state))
+ {}
+ };
 
     namespace future_state
     {
@@ -170,13 +171,6 @@
 
     namespace detail
     {
-#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
- template<typename F, typename Rp, typename Fp>
- struct future_deferred_continuation;
- template<typename F, typename Rp, typename Fp>
- struct future_async_continuation;
-#endif
-
         struct relocker
         {
             boost::unique_lock<boost::mutex>& lock_;
@@ -204,8 +198,15 @@
             relocker& operator=(relocker const&);
         };
 
- struct future_object_base : enable_shared_from_this<future_object_base>
+ struct shared_state_base : enable_shared_from_this<shared_state_base>
         {
+ typedef std::list<boost::condition_variable_any*> waiter_list;
+#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
+ typedef shared_ptr<shared_state_base> continuation_ptr_type;
+#else
+ // This type shouldn't be included, but is included to maintain the same layout.
+ typedef shared_ptr<void> continuation_ptr_type;
+#endif
 
             boost::exception_ptr exception;
             bool done;
@@ -214,56 +215,38 @@
             bool is_constructed;
             boost::mutex mutex;
             boost::condition_variable waiters;
- typedef std::list<boost::condition_variable_any*> waiter_list;
             waiter_list external_waiters;
             boost::function<void()> callback;
-//#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
+ // This declaration should be only included conditionally, but is included to maintain the same layout.
             bool thread_was_interrupted;
-//#endif
-#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
- typedef shared_ptr<future_object_base> continuation_ptr_type;
-#else
- typedef shared_ptr<void> continuation_ptr_type;
-#endif
+ // This declaration should be only included conditionally, but is included to maintain the same layout.
             continuation_ptr_type continuation_ptr;
 
-
-//#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
+ // This declaration should be only included conditionally, but is included to maintain the same layout.
             virtual void launch_continuation(boost::unique_lock<boost::mutex>&)
             {
             }
-//#endif
- future_object_base():
+
+ shared_state_base():
                 done(false),
                 is_deferred_(false),
                 policy_(launch::none),
- is_constructed(false)
-
- // This declaration should be only included conditinally, but are included to maintain the same layout.
-//#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
- , thread_was_interrupted(false)
-//#endif
- // This declaration should be only included conditinally, but are included to maintain the same layout.
-//#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
- , continuation_ptr()
-//#endif
+ is_constructed(false),
+ thread_was_interrupted(false),
+ continuation_ptr()
             {}
- virtual ~future_object_base()
+ virtual ~shared_state_base()
             {}
 
             void set_deferred()
             {
               is_deferred_ = true;
- set_launch_policy(launch::deferred);
+ policy_ = launch::deferred;
             }
             void set_async()
             {
               is_deferred_ = false;
- set_launch_policy(launch::async);
- }
- void set_launch_policy(launch policy)
- {
- policy_ = policy;
+ policy_ = launch::async;
             }
 
             waiter_list::iterator register_external_waiter(boost::condition_variable_any& cv)
@@ -330,23 +313,22 @@
                 }
             }
 
-
- void wait_internal(boost::unique_lock<boost::mutex> &lock, bool rethrow=true)
+ void wait_internal(boost::unique_lock<boost::mutex> &lk, bool rethrow=true)
             {
- do_callback(lock);
+ do_callback(lk);
               //if (!done) // fixme why this doesn't work?
               {
                 if (is_deferred_)
                 {
                   is_deferred_=false;
- execute(lock);
- //lock.unlock();
+ execute(lk);
+ //lk.unlock();
                 }
                 else
                 {
                   while(!done)
                   {
- waiters.wait(lock);
+ waiters.wait(lk);
                   }
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
                   if(rethrow && thread_was_interrupted)
@@ -361,7 +343,8 @@
                 }
               }
             }
- void wait(bool rethrow=true)
+
+ virtual void wait(bool rethrow=true)
             {
                 boost::unique_lock<boost::mutex> lock(mutex);
                 wait_internal(lock, rethrow);
@@ -412,11 +395,13 @@
                 exception=e;
                 mark_finished_internal(lock);
             }
+
             void mark_exceptional_finish()
             {
                 boost::unique_lock<boost::mutex> lock(mutex);
                 mark_exceptional_finish_internal(boost::current_exception(), lock);
             }
+
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
             void mark_interrupted_finish()
             {
@@ -424,6 +409,7 @@
                 thread_was_interrupted=true;
                 mark_finished_internal(lock);
             }
+
             void set_interrupted_at_thread_exit()
             {
               unique_lock<boost::mutex> lk(mutex);
@@ -435,6 +421,7 @@
               get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
             }
 #endif
+
             void set_exception_at_thread_exit(exception_ptr e)
             {
               unique_lock<boost::mutex> lk(mutex);
@@ -446,6 +433,7 @@
               this->is_constructed = true;
               get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
             }
+
             bool has_value()
             {
                 boost::lock_guard<boost::mutex> lock(mutex);
@@ -455,6 +443,7 @@
 #endif
                 );
             }
+
             bool has_value(unique_lock<boost::mutex>& )
             {
                 return done && !(exception
@@ -463,6 +452,7 @@
 #endif
                 );
             }
+
             bool has_exception()
             {
                 boost::lock_guard<boost::mutex> lock(mutex);
@@ -472,6 +462,7 @@
 #endif
                     );
             }
+
             bool has_exception(unique_lock<boost::mutex>&)
             {
                 return done && (exception
@@ -480,6 +471,7 @@
 #endif
                     );
             }
+
             bool is_deferred() const BOOST_NOEXCEPT {
                 return is_deferred_;
             }
@@ -489,17 +481,31 @@
                 return policy_;
             }
 
+ future_state::state get_state()
+ {
+ boost::lock_guard<boost::mutex> guard(mutex);
+ if(!done)
+ {
+ return future_state::waiting;
+ }
+ else
+ {
+ return future_state::ready;
+ }
+ }
+
             template<typename F,typename U>
             void set_wait_callback(F f,U* u)
             {
                 boost::lock_guard<boost::mutex> lock(mutex);
                 callback=boost::bind(f,boost::ref(*u));
             }
+
             virtual void execute(boost::unique_lock<boost::mutex>&) {}
 
         private:
- future_object_base(future_object_base const&);
- future_object_base& operator=(future_object_base const&);
+ shared_state_base(shared_state_base const&);
+ shared_state_base& operator=(shared_state_base const&);
         };
 
         template<typename T>
@@ -590,8 +596,8 @@
 
         // Used to create stand-alone futures
         template<typename T>
- struct future_object:
- detail::future_object_base
+ struct shared_state:
+ detail::shared_state_base
         {
             typedef typename future_traits<T>::storage_type storage_type;
             typedef typename future_traits<T>::source_reference_type source_reference_type;
@@ -601,11 +607,11 @@
 
             storage_type result;
 
- future_object():
+ shared_state():
                 result(0)
             {}
 
- ~future_object()
+ ~shared_state()
             {}
 
             void mark_finished_with_result_internal(source_reference_type result_, boost::unique_lock<boost::mutex>& lock)
@@ -641,34 +647,18 @@
 #endif
             }
 
-
             virtual move_dest_type get()
             {
                 wait();
                 return boost::move(*result);
             }
 
- shared_future_get_result_type get_sh()
+ virtual shared_future_get_result_type get_sh()
             {
                 wait();
                 return *result;
             }
 
- // todo move this to detail::future_object_base
- future_state::state get_state()
- {
- boost::lock_guard<boost::mutex> guard(mutex);
- if(!done)
- {
- return future_state::waiting;
- }
- else
- {
- return future_state::ready;
- }
- }
-
-
             //void set_value_at_thread_exit(const T & result_)
             void set_value_at_thread_exit(source_reference_type result_)
             {
@@ -697,27 +687,26 @@
 
 
         private:
- future_object(future_object const&);
- future_object& operator=(future_object const&);
+ shared_state(shared_state const&);
+ shared_state& operator=(shared_state const&);
         };
 
         template<typename T>
- struct future_object<T&>:
- detail::future_object_base
+ struct shared_state<T&>:
+ detail::shared_state_base
         {
             typedef typename future_traits<T&>::storage_type storage_type;
             typedef typename future_traits<T&>::source_reference_type source_reference_type;
- //typedef typename future_traits<T&>::rvalue_source_type rvalue_source_type;
             typedef typename future_traits<T&>::move_dest_type move_dest_type;
             typedef typename future_traits<T&>::shared_future_get_result_type shared_future_get_result_type;
 
             T* result;
 
- future_object():
+ shared_state():
                 result(0)
             {}
 
- ~future_object()
+ ~shared_state()
             {
             }
 
@@ -728,53 +717,24 @@
                 mark_finished_internal(lock);
             }
 
-// void mark_finished_with_result_internal(rvalue_source_type result_, boost::unique_lock<boost::mutex>& lock)
-// {
-// future_traits<T&>::init(result,static_cast<rvalue_source_type>(result_));
-// mark_finished_internal(lock);
-// }
-
             void mark_finished_with_result(source_reference_type result_)
             {
                 boost::unique_lock<boost::mutex> lock(mutex);
                 mark_finished_with_result_internal(result_, lock);
             }
 
-// void mark_finished_with_result(rvalue_source_type result_)
-// {
-// boost::unique_lock<boost::mutex> lock(mutex);
-// mark_finished_with_result_internal(static_cast<rvalue_source_type>(result_), lock);
-// }
-
-
- T& get()
+ virtual T& get()
             {
                 wait();
- //return static_cast<T&>(*result);
                 return *result;
             }
 
- T& get_sh()
+ virtual T& get_sh()
             {
                 wait();
- //return static_cast<shared_future_get_result_type>(*result);
                 return *result;
             }
 
- // todo move this to detail::future_object_base
- future_state::state get_state()
- {
- boost::lock_guard<boost::mutex> guard(mutex);
- if(!done)
- {
- return future_state::waiting;
- }
- else
- {
- return future_state::ready;
- }
- }
-
             void set_value_at_thread_exit(T& result_)
             {
               unique_lock<boost::mutex> lk(this->mutex);
@@ -785,29 +745,19 @@
               this->is_constructed = true;
               get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
             }
-// void set_value_at_thread_exit(rvalue_source_type result_)
-// {
-// unique_lock<boost::mutex> lk(this->mutex);
-// if (this->has_value())
-// throw_exception(promise_already_satisfied());
-// future_traits<T>::init(result,static_cast<rvalue_source_type>(result_));
-// this->is_constructed = true;
-// get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
-// }
-
 
         private:
- future_object(future_object const&);
- future_object& operator=(future_object const&);
+ shared_state(shared_state const&);
+ shared_state& operator=(shared_state const&);
         };
 
         template<>
- struct future_object<void>:
- detail::future_object_base
+ struct shared_state<void>:
+ detail::shared_state_base
         {
           typedef void shared_future_get_result_type;
 
- future_object()
+ shared_state()
             {}
 
             void mark_finished_with_result_internal(boost::unique_lock<boost::mutex>& lock)
@@ -821,27 +771,16 @@
                 mark_finished_with_result_internal(lock);
             }
 
- void get()
+ virtual void get()
             {
                 this->wait();
             }
- void get_sh()
+
+ virtual void get_sh()
             {
                 wait();
             }
- // todo move this to detail::future_object_base
- future_state::state get_state()
- {
- boost::lock_guard<boost::mutex> guard(mutex);
- if(!done)
- {
- return future_state::waiting;
- }
- else
- {
- return future_state::ready;
- }
- }
+
             void set_value_at_thread_exit()
             {
               unique_lock<boost::mutex> lk(this->mutex);
@@ -849,50 +788,61 @@
               {
                   throw_exception(promise_already_satisfied());
               }
- this->is_constructed = true;
+ this->is_constructed = true;
               get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
             }
         private:
- future_object(future_object const&);
- future_object& operator=(future_object const&);
+ shared_state(shared_state const&);
+ shared_state& operator=(shared_state const&);
         };
 
         /////////////////////////
- /// future_async_object
+ /// future_async_shared_state_base
         /////////////////////////
- template<typename Rp, typename Fp>
- struct future_async_object: future_object<Rp>
+ template<typename Rp>
+ struct future_async_shared_state_base: shared_state<Rp>
         {
- typedef future_object<Rp> base_type;
- typedef typename base_type::move_dest_type move_dest_type;
-
+ typedef shared_state<Rp> base_type;
           boost::thread thr_;
 
         public:
- explicit future_async_object(BOOST_THREAD_FWD_REF(Fp) f) :
- thr_(&future_async_object::run, this, boost::forward<Fp>(f))
+ future_async_shared_state_base()
+ {
+ this->set_async();
+ }
+ explicit future_async_shared_state_base(BOOST_THREAD_RV_REF(boost::thread) th) :
+ thr_(boost::move(th))
           {
             this->set_async();
           }
 
- ~future_async_object()
+ ~future_async_shared_state_base()
           {
             if (thr_.joinable()) thr_.join();
           }
 
- move_dest_type get()
+ virtual void wait(bool rethrow)
           {
               if (thr_.joinable()) thr_.join();
- // fixme Is the lock needed during the whole scope?
- //this->wait();
- boost::unique_lock<boost::mutex> lock(this->mutex);
- this->wait_internal(lock);
-
- //return static_cast<move_dest_type>(*(this->result));
- //return boost::move<Rp>(*(this->result));
- return boost::move(*(this->result));
+ this->base_type::wait(rethrow);
+ }
+ };
+
+ /////////////////////////
+ /// future_async_shared_state
+ /////////////////////////
+ template<typename Rp, typename Fp>
+ struct future_async_shared_state: future_async_shared_state_base<Rp>
+ {
+ typedef future_async_shared_state_base<Rp> base_type;
+
+ public:
+ explicit future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f) :
+ base_type(thread(&future_async_shared_state::run, this, boost::forward<Fp>(f)))
+ {
           }
- static void run(future_async_object* that, BOOST_THREAD_FWD_REF(Fp) f)
+
+ static void run(future_async_shared_state* that, BOOST_THREAD_FWD_REF(Fp) f)
           {
             try
             {
@@ -912,24 +862,17 @@
         };
 
         template<typename Fp>
- struct future_async_object<void, Fp>: public future_object<void>
+ struct future_async_shared_state<void, Fp>: public future_async_shared_state_base<void>
         {
- typedef future_object<void> base_type;
- boost::thread thr_;
+ typedef future_async_shared_state_base<void> base_type;
 
         public:
- explicit future_async_object(BOOST_THREAD_FWD_REF(Fp) f) :
- thr_(&future_async_object::run, this, boost::forward<Fp>(f))
- {
- this->set_async();
- }
-
- ~future_async_object()
+ explicit future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f) :
+ base_type(thread(&future_async_shared_state::run, this, boost::forward<Fp>(f)))
           {
- if (thr_.joinable()) thr_.join();
           }
 
- static void run(future_async_object* that, BOOST_THREAD_FWD_REF(Fp) f)
+ static void run(future_async_shared_state* that, BOOST_THREAD_FWD_REF(Fp) f)
           {
             try
             {
@@ -950,37 +893,17 @@
         };
 
         template<typename Rp, typename Fp>
- struct future_async_object<Rp&, Fp>: future_object<Rp&>
+ struct future_async_shared_state<Rp&, Fp>: future_async_shared_state_base<Rp&>
         {
- typedef future_object<Rp&> base_type;
- typedef typename base_type::move_dest_type move_dest_type;
-
- boost::thread thr_;
+ typedef future_async_shared_state_base<Rp&> base_type;
 
         public:
- explicit future_async_object(BOOST_THREAD_FWD_REF(Fp) f) :
- thr_(&future_async_object::run, this, boost::forward<Fp>(f))
- {
- this->set_async();
- }
-
- ~future_async_object()
+ explicit future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f) :
+ base_type(thread(&future_async_shared_state::run, this, boost::forward<Fp>(f)))
           {
- if (thr_.joinable()) thr_.join();
           }
 
- move_dest_type get()
- {
- if (thr_.joinable()) thr_.join();
- // fixme Is the lock needed during the whole scope?
- //this->wait();
- boost::unique_lock<boost::mutex> lock(this->mutex);
- this->wait_internal(lock);
-
- //return static_cast<move_dest_type>(*(this->result));
- return boost::move(*(this->result));
- }
- static void run(future_async_object* that, BOOST_THREAD_FWD_REF(Fp) f)
+ static void run(future_async_shared_state* that, BOOST_THREAD_FWD_REF(Fp) f)
           {
             try
             {
@@ -1000,16 +923,16 @@
         };
 
         //////////////////////////
- /// future_deferred_object
+ /// future_deferred_shared_state
         //////////////////////////
         template<typename Rp, typename Fp>
- struct future_deferred_object: future_object<Rp>
+ struct future_deferred_shared_state: shared_state<Rp>
         {
- typedef future_object<Rp> base_type;
+ typedef shared_state<Rp> base_type;
           Fp func_;
 
         public:
- explicit future_deferred_object(BOOST_THREAD_FWD_REF(Fp) f)
+ explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f)
           : func_(boost::forward<Fp>(f))
           {
             this->set_deferred();
@@ -1027,13 +950,13 @@
           }
         };
         template<typename Rp, typename Fp>
- struct future_deferred_object<Rp&,Fp>: future_object<Rp&>
+ struct future_deferred_shared_state<Rp&,Fp>: shared_state<Rp&>
         {
- typedef future_object<Rp&> base_type;
+ typedef shared_state<Rp&> base_type;
           Fp func_;
 
         public:
- explicit future_deferred_object(BOOST_THREAD_FWD_REF(Fp) f)
+ explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f)
           : func_(boost::forward<Fp>(f))
           {
             this->set_deferred();
@@ -1052,13 +975,13 @@
         };
 
         template<typename Fp>
- struct future_deferred_object<void,Fp>: future_object<void>
+ struct future_deferred_shared_state<void,Fp>: shared_state<void>
         {
- typedef future_object<void> base_type;
+ typedef shared_state<void> base_type;
           Fp func_;
 
         public:
- explicit future_deferred_object(BOOST_THREAD_FWD_REF(Fp) f)
+ explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f)
           : func_(boost::forward<Fp>(f))
           {
             this->set_deferred();
@@ -1078,13 +1001,13 @@
         };
 
 // template<typename T, typename Allocator>
-// struct future_object_alloc: public future_object<T>
+// struct shared_state_alloc: public shared_state<T>
 // {
-// typedef future_object<T> base;
+// typedef shared_state<T> base;
 // Allocator alloc_;
 //
 // public:
-// explicit future_object_alloc(const Allocator& a)
+// explicit shared_state_alloc(const Allocator& a)
 // : alloc_(a) {}
 //
 // };
@@ -1095,12 +1018,12 @@
 
             struct registered_waiter
             {
- boost::shared_ptr<detail::future_object_base> future_;
- detail::future_object_base::waiter_list::iterator wait_iterator;
+ boost::shared_ptr<detail::shared_state_base> future_;
+ detail::shared_state_base::waiter_list::iterator wait_iterator;
                 count_type index;
 
- registered_waiter(boost::shared_ptr<detail::future_object_base> const& a_future,
- detail::future_object_base::waiter_list::iterator wait_iterator_,
+ registered_waiter(boost::shared_ptr<detail::shared_state_base> const& a_future,
+ detail::shared_state_base::waiter_list::iterator wait_iterator_,
                                   count_type index_):
                     future_(a_future),wait_iterator(wait_iterator_),index(index_)
                 {}
@@ -1124,7 +1047,7 @@
 #if defined __DECCXX || defined __SUNPRO_CC || defined __hpux
                         locks[i]=boost::unique_lock<boost::mutex>(futures[i].future_->mutex).move();
 #else
- locks[i]=boost::unique_lock<boost::mutex>(futures[i].future_->mutex); // TODO shouldn't be moved explicitly
+ locks[i]=boost::unique_lock<boost::mutex>(futures[i].future_->mutex);
 #endif
                     }
                 }
@@ -1200,18 +1123,21 @@
     struct is_future_type
     {
         BOOST_STATIC_CONSTANT(bool, value=false);
+ typedef void type;
     };
 
     template<typename T>
     struct is_future_type<BOOST_THREAD_FUTURE<T> >
     {
         BOOST_STATIC_CONSTANT(bool, value=true);
+ typedef T type;
     };
 
     template<typename T>
     struct is_future_type<shared_future<T> >
     {
         BOOST_STATIC_CONSTANT(bool, value=true);
+ typedef T type;
     };
 
     template<typename Iterator>
@@ -1332,8 +1258,9 @@
       class basic_future : public base_future
       {
       protected:
+ public:
 
- typedef boost::shared_ptr<detail::future_object<R> > future_ptr;
+ typedef boost::shared_ptr<detail::shared_state<R> > future_ptr;
 
         future_ptr future_;
 
@@ -1458,23 +1385,33 @@
 #if (!defined _MSC_VER || _MSC_VER >= 1400) // _MSC_VER == 1400 on MSVC 2005
         template <class Rp, class Fp>
         BOOST_THREAD_FUTURE<Rp>
- make_future_async_object(BOOST_THREAD_FWD_REF(Fp) f);
+ make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
 
         template <class Rp, class Fp>
         BOOST_THREAD_FUTURE<Rp>
- make_future_deferred_object(BOOST_THREAD_FWD_REF(Fp) f);
+ make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
 #endif // #if (!defined _MSC_VER || _MSC_VER >= 1400)
-
 #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
+ template<typename F, typename Rp, typename Fp>
+ struct future_deferred_continuation_shared_state;
+ template<typename F, typename Rp, typename Fp>
+ struct future_async_continuation_shared_state;
+
         template <class F, class Rp, class Fp>
         BOOST_THREAD_FUTURE<Rp>
- make_future_async_continuation(boost::unique_lock<boost::mutex> &lock, F& f, BOOST_THREAD_FWD_REF(Fp) c);
+ make_future_async_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
 
         template <class F, class Rp, class Fp>
         BOOST_THREAD_FUTURE<Rp>
- make_future_deferred_continuation(boost::unique_lock<boost::mutex> &lock, F& f, BOOST_THREAD_FWD_REF(Fp) c);
+ make_future_deferred_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
+#endif
+#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
+ template<typename F, typename Rp>
+ struct future_unwrap_shared_state;
+ template <class F, class Rp>
+ inline BOOST_THREAD_FUTURE<Rp>
+ make_future_unwrap_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f);
 #endif
-
     }
 
     template <typename R>
@@ -1488,9 +1425,24 @@
         friend class promise<R>;
 #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
         template <typename, typename, typename>
- friend struct detail::future_async_continuation;
+ friend struct detail::future_async_continuation_shared_state;
         template <typename, typename, typename>
- friend struct detail::future_deferred_continuation;
+ friend struct detail::future_deferred_continuation_shared_state;
+
+ template <class F, class Rp, class Fp>
+ friend BOOST_THREAD_FUTURE<Rp>
+ detail::make_future_async_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
+
+ template <class F, class Rp, class Fp>
+ friend BOOST_THREAD_FUTURE<Rp>
+ detail::make_future_deferred_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
+#endif
+#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
+ template<typename F, typename Rp>
+ friend struct detail::future_unwrap_shared_state;
+ template <class F, class Rp>
+ friend BOOST_THREAD_FUTURE<Rp>
+ detail::make_future_unwrap_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f);
 #endif
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
         template <class> friend class packaged_task; // todo check if this works in windows
@@ -1501,21 +1453,12 @@
 
         template <class Rp, class Fp>
         friend BOOST_THREAD_FUTURE<Rp>
- detail::make_future_async_object(BOOST_THREAD_FWD_REF(Fp) f);
+ detail::make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
 
         template <class Rp, class Fp>
         friend BOOST_THREAD_FUTURE<Rp>
- detail::make_future_deferred_object(BOOST_THREAD_FWD_REF(Fp) f);
-
-#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
- template <class F, class Rp, class Fp>
- friend BOOST_THREAD_FUTURE<Rp>
- detail::make_future_async_continuation(boost::unique_lock<boost::mutex> &lock, F& f, BOOST_THREAD_FWD_REF(Fp) c);
+ detail::make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
 
- template <class F, class Rp, class Fp>
- friend BOOST_THREAD_FUTURE<Rp>
- detail::make_future_deferred_continuation(boost::unique_lock<boost::mutex> &lock, F& f, BOOST_THREAD_FWD_REF(Fp) c);
-#endif
 
         typedef typename detail::future_traits<R>::move_dest_type move_dest_type;
 
@@ -1527,6 +1470,7 @@
     public:
         BOOST_THREAD_MOVABLE_ONLY(BOOST_THREAD_FUTURE)
         typedef future_state::state state;
+ typedef R value_type; // EXTENSION
 
         BOOST_CONSTEXPR BOOST_THREAD_FUTURE() {}
 
@@ -1536,6 +1480,7 @@
         base_type(boost::move(static_cast<base_type&>(BOOST_THREAD_RV(other))))
         {
         }
+ inline BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE<BOOST_THREAD_FUTURE<R> >) other); // EXTENSION
 
         BOOST_THREAD_FUTURE& operator=(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT
         {
@@ -1553,12 +1498,12 @@
             static_cast<base_type*>(this)->swap(other);
         }
 
- // todo this functioˆn must be private and friendship provided to the internal users.
+ // todo this function must be private and friendship provided to the internal users.
         void set_async()
         {
           this->future_->set_async();
         }
- // todo this functioˆn must be private and friendship provided to the internal users.
+ // todo this function must be private and friendship provided to the internal users.
         void set_deferred()
         {
           this->future_->set_deferred();
@@ -1571,14 +1516,53 @@
             {
                 boost::throw_exception(future_uninitialized());
             }
-#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
             future_ptr fut_=this->future_;
+#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
             this->future_.reset();
+#endif
             return fut_->get();
+ }
 
-#else
- return this->future_->get();
+ template <typename R2>
+ typename disable_if< is_void<R2>, move_dest_type>::type
+ get_or(BOOST_THREAD_RV_REF(R2) v)
+ {
+ if(!this->future_)
+ {
+ boost::throw_exception(future_uninitialized());
+ }
+ this->future_->wait(false);
+ future_ptr fut_=this->future_;
+#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
+ this->future_.reset();
+#endif
+ if (fut_->has_value()) {
+ return fut_->get();
+ }
+ else {
+ return boost::move(v);
+ }
+ }
+
+ template <typename R2>
+ typename disable_if< is_void<R2>, move_dest_type>::type
+ get_or(R2 const& v) // EXTENSION
+ {
+ if(!this->future_)
+ {
+ boost::throw_exception(future_uninitialized());
+ }
+ this->future_->wait(false);
+ future_ptr fut_=this->future_;
+#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
+ this->future_.reset();
 #endif
+ if (fut_->has_value()) {
+ return fut_->get();
+ }
+ else {
+ return v;
+ }
         }
 
 
@@ -1594,16 +1578,202 @@
 // inline BOOST_THREAD_FUTURE<RF> then(launch policy, RF(*func)(BOOST_THREAD_FUTURE&));
 //#endif
         template<typename F>
- inline BOOST_THREAD_FUTURE<typename boost::result_of<F(BOOST_THREAD_FUTURE&)>::type>
- then(BOOST_THREAD_FWD_REF(F) func);
+ inline BOOST_THREAD_FUTURE<typename boost::result_of<F(BOOST_THREAD_FUTURE)>::type>
+ then(BOOST_THREAD_FWD_REF(F) func); // EXTENSION
         template<typename F>
- inline BOOST_THREAD_FUTURE<typename boost::result_of<F(BOOST_THREAD_FUTURE&)>::type>
- then(launch policy, BOOST_THREAD_FWD_REF(F) func);
+ inline BOOST_THREAD_FUTURE<typename boost::result_of<F(BOOST_THREAD_FUTURE)>::type>
+ then(launch policy, BOOST_THREAD_FWD_REF(F) func); // EXTENSION
+
+ template <typename R2>
+ inline typename disable_if< is_void<R2>, BOOST_THREAD_FUTURE<R> >::type
+ fallback_to(BOOST_THREAD_RV_REF(R2) v); // EXTENSION
+ template <typename R2>
+ inline typename disable_if< is_void<R2>, BOOST_THREAD_FUTURE<R> >::type
+ fallback_to(R2 const& v); // EXTENSION
+
 #endif
+
+//#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
+// inline
+// typename enable_if<
+// is_future_type<value_type>,
+// value_type
+// //BOOST_THREAD_FUTURE<typename is_future_type<value_type>::type>
+// >::type
+// unwrap();
+//#endif
+
     };
 
     BOOST_THREAD_DCL_MOVABLE_BEG(T) BOOST_THREAD_FUTURE<T> BOOST_THREAD_DCL_MOVABLE_END
 
+ template <typename R2>
+ class BOOST_THREAD_FUTURE<BOOST_THREAD_FUTURE<R2> > : public detail::basic_future<BOOST_THREAD_FUTURE<R2> >
+ {
+ typedef BOOST_THREAD_FUTURE<R2> R;
+
+ private:
+ typedef detail::basic_future<R> base_type;
+ typedef typename base_type::future_ptr future_ptr;
+
+ friend class shared_future<R>;
+ friend class promise<R>;
+ #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
+ template <typename, typename, typename>
+ friend struct detail::future_async_continuation_shared_state;
+ template <typename, typename, typename>
+ friend struct detail::future_deferred_continuation_shared_state;
+
+ template <class F, class Rp, class Fp>
+ friend BOOST_THREAD_FUTURE<Rp>
+ detail::make_future_async_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
+
+ template <class F, class Rp, class Fp>
+ friend BOOST_THREAD_FUTURE<Rp>
+ detail::make_future_deferred_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
+ #endif
+#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
+ template<typename F, typename Rp>
+ friend struct detail::future_unwrap_shared_state;
+ template <class F, class Rp>
+ friend BOOST_THREAD_FUTURE<Rp>
+ detail::make_future_unwrap_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f);
+#endif
+ #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
+ template <class> friend class packaged_task; // todo check if this works in windows
+ #else
+ friend class packaged_task<R>;
+ #endif
+ friend class detail::future_waiter;
+
+ template <class Rp, class Fp>
+ friend BOOST_THREAD_FUTURE<Rp>
+ detail::make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
+
+ template <class Rp, class Fp>
+ friend BOOST_THREAD_FUTURE<Rp>
+ detail::make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
+
+
+ typedef typename detail::future_traits<R>::move_dest_type move_dest_type;
+
+ BOOST_THREAD_FUTURE(future_ptr a_future):
+ base_type(a_future)
+ {
+ }
+
+ public:
+ BOOST_THREAD_MOVABLE_ONLY(BOOST_THREAD_FUTURE)
+ typedef future_state::state state;
+ typedef R value_type; // EXTENSION
+
+ BOOST_CONSTEXPR BOOST_THREAD_FUTURE() {}
+
+ ~BOOST_THREAD_FUTURE() {}
+
+ BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT:
+ base_type(boost::move(static_cast<base_type&>(BOOST_THREAD_RV(other))))
+ {
+ }
+
+ BOOST_THREAD_FUTURE& operator=(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT
+ {
+ this->base_type::operator=(boost::move(static_cast<base_type&>(BOOST_THREAD_RV(other))));
+ return *this;
+ }
+
+ shared_future<R> share()
+ {
+ return shared_future<R>(::boost::move(*this));
+ }
+
+ void swap(BOOST_THREAD_FUTURE& other)
+ {
+ static_cast<base_type*>(this)->swap(other);
+ }
+
+ // todo this function must be private and friendship provided to the internal users.
+ void set_async()
+ {
+ this->future_->set_async();
+ }
+ // todo this function must be private and friendship provided to the internal users.
+ void set_deferred()
+ {
+ this->future_->set_deferred();
+ }
+
+ // retrieving the value
+ move_dest_type get()
+ {
+ if(!this->future_)
+ {
+ boost::throw_exception(future_uninitialized());
+ }
+ future_ptr fut_=this->future_;
+ #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
+ this->future_.reset();
+ #endif
+ return fut_->get();
+ }
+ move_dest_type get_or(BOOST_THREAD_RV_REF(R) v) // EXTENSION
+ {
+ if(!this->future_)
+ {
+ boost::throw_exception(future_uninitialized());
+ }
+ this->future_->wait(false);
+ future_ptr fut_=this->future_;
+ #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
+ this->future_.reset();
+ #endif
+ if (fut_->has_value()) return fut_->get();
+ else return boost::move(v);
+ }
+
+ move_dest_type get_or(R const& v) // EXTENSION
+ {
+ if(!this->future_)
+ {
+ boost::throw_exception(future_uninitialized());
+ }
+ this->future_->wait(false);
+ future_ptr fut_=this->future_;
+ #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
+ this->future_.reset();
+ #endif
+ if (fut_->has_value()) return fut_->get();
+ else return v;
+ }
+
+
+ #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
+
+ // template<typename F>
+ // auto then(F&& func) -> BOOST_THREAD_FUTURE<decltype(func(*this))>;
+
+ //#if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR)
+ // template<typename RF>
+ // inline BOOST_THREAD_FUTURE<RF> then(RF(*func)(BOOST_THREAD_FUTURE&));
+ // template<typename RF>
+ // inline BOOST_THREAD_FUTURE<RF> then(launch policy, RF(*func)(BOOST_THREAD_FUTURE&));
+ //#endif
+ template<typename F>
+ inline BOOST_THREAD_FUTURE<typename boost::result_of<F(BOOST_THREAD_FUTURE)>::type>
+ then(BOOST_THREAD_FWD_REF(F) func); // EXTENSION
+ template<typename F>
+ inline BOOST_THREAD_FUTURE<typename boost::result_of<F(BOOST_THREAD_FUTURE)>::type>
+ then(launch policy, BOOST_THREAD_FWD_REF(F) func); // EXTENSION
+ #endif
+
+ #if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
+ inline
+ BOOST_THREAD_FUTURE<R2>
+ unwrap(); // EXTENSION
+ #endif
+
+ };
+
     template <typename R>
     class shared_future : public detail::basic_future<R>
     {
@@ -1614,6 +1784,20 @@
         friend class detail::future_waiter;
         friend class promise<R>;
 
+#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
+ template <typename, typename, typename>
+ friend struct detail::future_async_continuation_shared_state;
+ template <typename, typename, typename>
+ friend struct detail::future_deferred_continuation_shared_state;
+
+ template <class F, class Rp, class Fp>
+ friend BOOST_THREAD_FUTURE<Rp>
+ detail::make_future_async_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
+
+ template <class F, class Rp, class Fp>
+ friend BOOST_THREAD_FUTURE<Rp>
+ detail::make_future_deferred_continuation_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
+#endif
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
         template <class> friend class packaged_task;// todo check if this works in windows
 #else
@@ -1625,6 +1809,7 @@
 
     public:
         BOOST_THREAD_MOVABLE(shared_future)
+ typedef R value_type; // EXTENSION
 
         shared_future(shared_future const& other):
         base_type(other)
@@ -1661,9 +1846,6 @@
         shared_future& operator=(BOOST_THREAD_RV_REF( BOOST_THREAD_FUTURE<R> ) other) BOOST_NOEXCEPT
         {
             base_type::operator=(boost::move(static_cast<base_type&>(BOOST_THREAD_RV(other))));
- //shared_future(boost::move(other)).swap(*this);
- //this->future_.swap(BOOST_THREAD_RV(other).future_);
- //BOOST_THREAD_RV(other).future_.reset();
             return *this;
         }
 
@@ -1673,7 +1855,7 @@
         }
 
         // retrieving the value
- typename detail::future_object<R>::shared_future_get_result_type get()
+ typename detail::shared_state<R>::shared_future_get_result_type get()
         {
             if(!this->future_)
             {
@@ -1683,6 +1865,49 @@
             return this->future_->get_sh();
         }
 
+ template <typename R2>
+ typename disable_if< is_void<R2>, typename detail::shared_state<R>::shared_future_get_result_type>::type
+ get_or(BOOST_THREAD_RV_REF(R2) v) // EXTENSION
+ {
+ if(!this->future_)
+ {
+ boost::throw_exception(future_uninitialized());
+ }
+ future_ptr fut_=this->future_;
+ fut_->wait();
+ if (fut_->has_value()) return fut_->get_sh();
+ else return boost::move(v);
+ }
+
+#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
+
+// template<typename F>
+// auto then(F&& func) -> BOOST_THREAD_FUTURE<decltype(func(*this))>;
+// template<typename F>
+// auto then(launch, F&& func) -> BOOST_THREAD_FUTURE<decltype(func(*this))>;
+
+//#if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR)
+// template<typename RF>
+// inline BOOST_THREAD_FUTURE<RF> then(RF(*func)(shared_future&));
+// template<typename RF>
+// inline BOOST_THREAD_FUTURE<RF> then(launch policy, RF(*func)(shared_future&));
+//#endif
+ template<typename F>
+ inline BOOST_THREAD_FUTURE<typename boost::result_of<F(shared_future)>::type>
+ then(BOOST_THREAD_FWD_REF(F) func); // EXTENSION
+ template<typename F>
+ inline BOOST_THREAD_FUTURE<typename boost::result_of<F(shared_future)>::type>
+ then(launch policy, BOOST_THREAD_FWD_REF(F) func); // EXTENSION
+#endif
+//#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
+// inline
+// typename enable_if_c<
+// is_future_type<value_type>::value,
+// BOOST_THREAD_FUTURE<typename is_future_type<value_type>::type>
+// >::type
+// unwrap();
+//#endif
+
     };
 
     BOOST_THREAD_DCL_MOVABLE_BEG(T) shared_future<T> BOOST_THREAD_DCL_MOVABLE_END
@@ -1700,7 +1925,7 @@
     template <typename R>
     class promise
     {
- typedef boost::shared_ptr<detail::future_object<R> > future_ptr;
+ typedef boost::shared_ptr<detail::shared_state<R> > future_ptr;
 
         future_ptr future_;
         bool future_obtained;
@@ -1712,7 +1937,7 @@
           if(!atomic_load(&future_))
             {
                 future_ptr blank;
- atomic_compare_exchange(&future_,&blank,future_ptr(new detail::future_object<R>));
+ atomic_compare_exchange(&future_,&blank,future_ptr(new detail::shared_state<R>));
             }
 #include <boost/detail/atomic_redef_macros.hpp>
 #endif
@@ -1724,11 +1949,11 @@
         template <class Allocator>
         promise(boost::allocator_arg_t, Allocator a)
         {
- typedef typename Allocator::template rebind<detail::future_object<R> >::other A2;
+ typedef typename Allocator::template rebind<detail::shared_state<R> >::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
- future_ = future_ptr(::new(a2.allocate(1)) detail::future_object<R>(), D(a2, 1) );
+ future_ = future_ptr(::new(a2.allocate(1)) detail::shared_state<R>(), D(a2, 1) );
           future_obtained = false;
         }
 #endif
@@ -1736,7 +1961,7 @@
 #if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY
             future_(),
 #else
- future_(new detail::future_object<R>()),
+ future_(new detail::shared_state<R>()),
 #endif
             future_obtained(false)
         {}
@@ -1829,7 +2054,11 @@
             }
             future_->mark_exceptional_finish_internal(p, lock);
         }
-
+ template <typename E>
+ void set_exception(E ex)
+ {
+ set_exception(copy_exception(ex));
+ }
         // setting the result with deferred notification
         void set_value_at_thread_exit(const R& r)
         {
@@ -1856,6 +2085,11 @@
           }
           future_->set_exception_at_thread_exit(e);
         }
+ template <typename E>
+ void set_exception_at_thread_exit(E ex)
+ {
+ set_exception_at_thread_exit(copy_exception(ex));
+ }
 
         template<typename F>
         void set_wait_callback(F f)
@@ -1869,7 +2103,7 @@
     template <typename R>
     class promise<R&>
     {
- typedef boost::shared_ptr<detail::future_object<R&> > future_ptr;
+ typedef boost::shared_ptr<detail::shared_state<R&> > future_ptr;
 
         future_ptr future_;
         bool future_obtained;
@@ -1881,7 +2115,7 @@
             if(!atomic_load(&future_))
             {
                 future_ptr blank;
- atomic_compare_exchange(&future_,&blank,future_ptr(new detail::future_object<R&>));
+ atomic_compare_exchange(&future_,&blank,future_ptr(new detail::shared_state<R&>));
             }
 #include <boost/detail/atomic_redef_macros.hpp>
 #endif
@@ -1893,11 +2127,11 @@
         template <class Allocator>
         promise(boost::allocator_arg_t, Allocator a)
         {
- typedef typename Allocator::template rebind<detail::future_object<R&> >::other A2;
+ typedef typename Allocator::template rebind<detail::shared_state<R&> >::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
- future_ = future_ptr(::new(a2.allocate(1)) detail::future_object<R&>(), D(a2, 1) );
+ future_ = future_ptr(::new(a2.allocate(1)) detail::shared_state<R&>(), D(a2, 1) );
           future_obtained = false;
         }
 #endif
@@ -1905,7 +2139,7 @@
 #if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY
             future_(),
 #else
- future_(new detail::future_object<R&>()),
+ future_(new detail::shared_state<R&>()),
 #endif
             future_obtained(false)
         {}
@@ -1982,6 +2216,11 @@
             }
             future_->mark_exceptional_finish_internal(p, lock);
         }
+ template <typename E>
+ void set_exception(E ex)
+ {
+ set_exception(copy_exception(ex));
+ }
 
         // setting the result with deferred notification
         void set_value_at_thread_exit(R& r)
@@ -2001,6 +2240,11 @@
           }
           future_->set_exception_at_thread_exit(e);
         }
+ template <typename E>
+ void set_exception_at_thread_exit(E ex)
+ {
+ set_exception_at_thread_exit(copy_exception(ex));
+ }
 
         template<typename F>
         void set_wait_callback(F f)
@@ -2013,7 +2257,7 @@
     template <>
     class promise<void>
     {
- typedef boost::shared_ptr<detail::future_object<void> > future_ptr;
+ typedef boost::shared_ptr<detail::shared_state<void> > future_ptr;
 
         future_ptr future_;
         bool future_obtained;
@@ -2024,7 +2268,7 @@
             if(!atomic_load(&future_))
             {
                 future_ptr blank;
- atomic_compare_exchange(&future_,&blank,future_ptr(new detail::future_object<void>));
+ atomic_compare_exchange(&future_,&blank,future_ptr(new detail::shared_state<void>));
             }
 #endif
         }
@@ -2035,11 +2279,11 @@
         template <class Allocator>
         promise(boost::allocator_arg_t, Allocator a)
         {
- typedef typename Allocator::template rebind<detail::future_object<void> >::other A2;
+ typedef typename Allocator::template rebind<detail::shared_state<void> >::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
- future_ = future_ptr(::new(a2.allocate(1)) detail::future_object<void>(), D(a2, 1) );
+ future_ = future_ptr(::new(a2.allocate(1)) detail::shared_state<void>(), D(a2, 1) );
           future_obtained = false;
         }
 #endif
@@ -2047,7 +2291,7 @@
 #if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY
             future_(),
 #else
- future_(new detail::future_object<void>),
+ future_(new detail::shared_state<void>),
 #endif
             future_obtained(false)
         {}
@@ -2127,6 +2371,11 @@
             }
             future_->mark_exceptional_finish_internal(p,lock);
         }
+ template <typename E>
+ void set_exception(E ex)
+ {
+ set_exception(copy_exception(ex));
+ }
 
         // setting the result with deferred notification
         void set_value_at_thread_exit()
@@ -2146,6 +2395,11 @@
           }
           future_->set_exception_at_thread_exit(e);
         }
+ template <typename E>
+ void set_exception_at_thread_exit(E ex)
+ {
+ set_exception_at_thread_exit(copy_exception(ex));
+ }
 
         template<typename F>
         void set_wait_callback(F f)
@@ -2172,23 +2426,23 @@
     {
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
       template<typename R>
- struct task_base;
+ struct task_base_shared_state;
 #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
       template<typename R, typename ...ArgTypes>
- struct task_base<R(ArgTypes...)>:
+ struct task_base_shared_state<R(ArgTypes...)>:
 #else
       template<typename R>
- struct task_base<R()>:
+ struct task_base_shared_state<R()>:
 #endif
 #else
       template<typename R>
- struct task_base:
+ struct task_base_shared_state:
 #endif
- detail::future_object<R>
+ detail::shared_state<R>
         {
             bool started;
 
- task_base():
+ task_base_shared_state():
                 started(false)
             {}
 
@@ -2256,30 +2510,30 @@
 
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
         template<typename F, typename R>
- struct task_object;
+ struct task_shared_state;
 #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
         template<typename F, typename R, typename ...ArgTypes>
- struct task_object<F, R(ArgTypes...)>:
- task_base<R(ArgTypes...)>
+ struct task_shared_state<F, R(ArgTypes...)>:
+ task_base_shared_state<R(ArgTypes...)>
 #else
         template<typename F, typename R>
- struct task_object<F, R()>:
- task_base<R()>
+ struct task_shared_state<F, R()>:
+ task_base_shared_state<R()>
 #endif
 #else
         template<typename F, typename R>
- struct task_object:
- task_base<R>
+ struct task_shared_state:
+ task_base_shared_state<R>
 #endif
         {
         private:
- task_object(task_object&);
+ task_shared_state(task_shared_state&);
         public:
             F f;
- task_object(F const& f_):
+ task_shared_state(F const& f_):
                 f(f_)
             {}
- task_object(BOOST_THREAD_RV_REF(F) f_):
+ task_shared_state(BOOST_THREAD_RV_REF(F) f_):
               f(boost::move(f_))
             {}
 
@@ -2346,27 +2600,27 @@
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
 #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
         template<typename F, typename R, typename ...ArgTypes>
- struct task_object<F, R&(ArgTypes...)>:
- task_base<R&(ArgTypes...)>
+ struct task_shared_state<F, R&(ArgTypes...)>:
+ task_base_shared_state<R&(ArgTypes...)>
 #else
         template<typename F, typename R>
- struct task_object<F, R&()>:
- task_base<R&()>
+ struct task_shared_state<F, R&()>:
+ task_base_shared_state<R&()>
 #endif
 #else
         template<typename F, typename R>
- struct task_object<F,R&>:
- task_base<R&>
+ struct task_shared_state<F,R&>:
+ task_base_shared_state<R&>
 #endif
         {
         private:
- task_object(task_object&);
+ task_shared_state(task_shared_state&);
         public:
             F f;
- task_object(F const& f_):
+ task_shared_state(F const& f_):
                 f(f_)
             {}
- task_object(BOOST_THREAD_RV_REF(F) f_):
+ task_shared_state(BOOST_THREAD_RV_REF(F) f_):
                 f(boost::move(f_))
             {}
 
@@ -2431,24 +2685,24 @@
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
 #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
         template<typename R, typename ...ArgTypes>
- struct task_object<R (*)(ArgTypes...), R(ArgTypes...)>:
- task_base<R(ArgTypes...)>
+ struct task_shared_state<R (*)(ArgTypes...), R(ArgTypes...)>:
+ task_base_shared_state<R(ArgTypes...)>
 #else
         template<typename R>
- struct task_object<R (*)(), R()>:
- task_base<R()>
+ struct task_shared_state<R (*)(), R()>:
+ task_base_shared_state<R()>
 #endif
 #else
         template<typename R>
- struct task_object<R (*)(), R> :
- task_base<R>
+ struct task_shared_state<R (*)(), R> :
+ task_base_shared_state<R>
 #endif
             {
             private:
- task_object(task_object&);
+ task_shared_state(task_shared_state&);
             public:
                 R (*f)();
- task_object(R (*f_)()):
+ task_shared_state(R (*f_)()):
                     f(f_)
                 {}
 
@@ -2513,24 +2767,24 @@
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
 #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
         template<typename R, typename ...ArgTypes>
- struct task_object<R& (*)(ArgTypes...), R&(ArgTypes...)>:
- task_base<R&(ArgTypes...)>
+ struct task_shared_state<R& (*)(ArgTypes...), R&(ArgTypes...)>:
+ task_base_shared_state<R&(ArgTypes...)>
 #else
         template<typename R>
- struct task_object<R& (*)(), R&()>:
- task_base<R&()>
+ struct task_shared_state<R& (*)(), R&()>:
+ task_base_shared_state<R&()>
 #endif
 #else
         template<typename R>
- struct task_object<R& (*)(), R&> :
- task_base<R&>
+ struct task_shared_state<R& (*)(), R&> :
+ task_base_shared_state<R&>
 #endif
             {
             private:
- task_object(task_object&);
+ task_shared_state(task_shared_state&);
             public:
                 R& (*f)();
- task_object(R& (*f_)()):
+ task_shared_state(R& (*f_)()):
                     f(f_)
                 {}
 
@@ -2594,27 +2848,27 @@
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
 #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
         template<typename F, typename ...ArgTypes>
- struct task_object<F, void(ArgTypes...)>:
- task_base<void(ArgTypes...)>
+ struct task_shared_state<F, void(ArgTypes...)>:
+ task_base_shared_state<void(ArgTypes...)>
 #else
         template<typename F>
- struct task_object<F, void()>:
- task_base<void()>
+ struct task_shared_state<F, void()>:
+ task_base_shared_state<void()>
 #endif
 #else
         template<typename F>
- struct task_object<F,void>:
- task_base<void>
+ struct task_shared_state<F,void>:
+ task_base_shared_state<void>
 #endif
         {
         private:
- task_object(task_object&);
+ task_shared_state(task_shared_state&);
         public:
             F f;
- task_object(F const& f_):
+ task_shared_state(F const& f_):
                 f(f_)
             {}
- task_object(BOOST_THREAD_RV_REF(F) f_):
+ task_shared_state(BOOST_THREAD_RV_REF(F) f_):
                 f(boost::move(f_))
             {}
 
@@ -2676,24 +2930,24 @@
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
 #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
         template<typename ...ArgTypes>
- struct task_object<void (*)(ArgTypes...), void(ArgTypes...)>:
- task_base<void(ArgTypes...)>
+ struct task_shared_state<void (*)(ArgTypes...), void(ArgTypes...)>:
+ task_base_shared_state<void(ArgTypes...)>
 #else
         template<>
- struct task_object<void (*)(), void()>:
- task_base<void()>
+ struct task_shared_state<void (*)(), void()>:
+ task_base_shared_state<void()>
 #endif
 #else
         template<>
- struct task_object<void (*)(),void>:
- task_base<void>
+ struct task_shared_state<void (*)(),void>:
+ task_base_shared_state<void>
 #endif
         {
         private:
- task_object(task_object&);
+ task_shared_state(task_shared_state&);
         public:
             void (*f)();
- task_object(void (*f_)()):
+ task_shared_state(void (*f_)()):
                 f(f_)
             {}
 
@@ -2751,30 +3005,28 @@
                 }
             }
         };
-
     }
 
-
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
     template<typename R, typename ...ArgTypes>
     class packaged_task<R(ArgTypes...)>
     {
- typedef boost::shared_ptr<detail::task_base<R(ArgTypes...)> > task_ptr;
- boost::shared_ptr<detail::task_base<R(ArgTypes...)> > task;
+ typedef boost::shared_ptr<detail::task_base_shared_state<R(ArgTypes...)> > task_ptr;
+ boost::shared_ptr<detail::task_base_shared_state<R(ArgTypes...)> > task;
   #else
     template<typename R>
     class packaged_task<R()>
     {
- typedef boost::shared_ptr<detail::task_base<R()> > task_ptr;
- boost::shared_ptr<detail::task_base<R()> > task;
+ typedef boost::shared_ptr<detail::task_base_shared_state<R()> > task_ptr;
+ boost::shared_ptr<detail::task_base_shared_state<R()> > task;
   #endif
 #else
     template<typename R>
     class packaged_task
     {
- typedef boost::shared_ptr<detail::task_base<R> > task_ptr;
- boost::shared_ptr<detail::task_base<R> > task;
+ typedef boost::shared_ptr<detail::task_base_shared_state<R> > task_ptr;
+ boost::shared_ptr<detail::task_base_shared_state<R> > task;
 #endif
         bool future_obtained;
         struct dummy;
@@ -2795,16 +3047,16 @@
         explicit packaged_task(R(*f)(), BOOST_THREAD_FWD_REF(ArgTypes)... args)
         {
             typedef R(*FR)(BOOST_THREAD_FWD_REF(ArgTypes)...);
- typedef detail::task_object<FR,R(ArgTypes...)> task_object_type;
- task= task_ptr(new task_object_type(f, boost::forward<ArgTypes>(args)...));
+ typedef detail::task_shared_state<FR,R(ArgTypes...)> task_shared_state_type;
+ task= task_ptr(new task_shared_state_type(f, boost::forward<ArgTypes>(args)...));
             future_obtained=false;
         }
   #else
         explicit packaged_task(R(*f)())
         {
             typedef R(*FR)();
- typedef detail::task_object<FR,R()> task_object_type;
- task= task_ptr(new task_object_type(f));
+ typedef detail::task_shared_state<FR,R()> task_shared_state_type;
+ task= task_ptr(new task_shared_state_type(f));
             future_obtained=false;
         }
   #endif
@@ -2812,8 +3064,8 @@
         explicit packaged_task(R(*f)())
         {
               typedef R(*FR)();
- typedef detail::task_object<FR,R> task_object_type;
- task= task_ptr(new task_object_type(f));
+ typedef detail::task_shared_state<FR,R> task_shared_state_type;
+ task= task_ptr(new task_shared_state_type(f));
             future_obtained=false;
         }
 #endif
@@ -2827,14 +3079,14 @@
           typedef typename remove_cv<typename remove_reference<F>::type>::type FR;
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- typedef detail::task_object<FR,R(ArgTypes...)> task_object_type;
+ typedef detail::task_shared_state<FR,R(ArgTypes...)> task_shared_state_type;
   #else
- typedef detail::task_object<FR,R()> task_object_type;
+ typedef detail::task_shared_state<FR,R()> task_shared_state_type;
   #endif
 #else
- typedef detail::task_object<FR,R> task_object_type;
+ typedef detail::task_shared_state<FR,R> task_shared_state_type;
 #endif
- task = task_ptr(new task_object_type(boost::forward<F>(f)));
+ task = task_ptr(new task_shared_state_type(boost::forward<F>(f)));
             future_obtained = false;
 
         }
@@ -2847,14 +3099,14 @@
         {
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- typedef detail::task_object<F,R(ArgTypes...)> task_object_type;
+ typedef detail::task_shared_state<F,R(ArgTypes...)> task_shared_state_type;
   #else
- typedef detail::task_object<F,R()> task_object_type;
+ typedef detail::task_shared_state<F,R()> task_shared_state_type;
   #endif
 #else
- typedef detail::task_object<F,R> task_object_type;
+ typedef detail::task_shared_state<F,R> task_shared_state_type;
 #endif
- task = task_ptr(new task_object_type(f));
+ task = task_ptr(new task_shared_state_type(f));
             future_obtained=false;
         }
         template <class F>
@@ -2862,15 +3114,15 @@
         {
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
 #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- typedef detail::task_object<F,R(ArgTypes...)> task_object_type;
- task = task_ptr(new task_object_type(boost::forward<F>(f)));
+ typedef detail::task_shared_state<F,R(ArgTypes...)> task_shared_state_type;
+ task = task_ptr(new task_shared_state_type(boost::forward<F>(f)));
 #else
- typedef detail::task_object<F,R()> task_object_type;
- task = task_ptr(new task_object_type(boost::move<F>(f))); // TODO forward
+ typedef detail::task_shared_state<F,R()> task_shared_state_type;
+ task = task_ptr(new task_shared_state_type(boost::move(f))); // TODO forward
 #endif
 #else
- typedef detail::task_object<F,R> task_object_type;
- task = task_ptr(new task_object_type(boost::forward<F>(f)));
+ typedef detail::task_shared_state<F,R> task_shared_state_type;
+ task = task_ptr(new task_shared_state_type(boost::forward<F>(f)));
 #endif
             future_obtained=false;
 
@@ -2885,18 +3137,18 @@
           typedef R(*FR)();
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- typedef detail::task_object<FR,R(ArgTypes...)> task_object_type;
+ typedef detail::task_shared_state<FR,R(ArgTypes...)> task_shared_state_type;
   #else
- typedef detail::task_object<FR,R()> task_object_type;
+ typedef detail::task_shared_state<FR,R()> task_shared_state_type;
   #endif
 #else
- typedef detail::task_object<FR,R> task_object_type;
+ typedef detail::task_shared_state<FR,R> task_shared_state_type;
 #endif
- typedef typename Allocator::template rebind<task_object_type>::other A2;
+ typedef typename Allocator::template rebind<task_shared_state_type>::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
- task = task_ptr(::new(a2.allocate(1)) task_object_type(f), D(a2, 1) );
+ task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(f), D(a2, 1) );
           future_obtained = false;
         }
 #endif // BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
@@ -2908,18 +3160,18 @@
           typedef typename remove_cv<typename remove_reference<F>::type>::type FR;
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- typedef detail::task_object<FR,R(ArgTypes...)> task_object_type;
+ typedef detail::task_shared_state<FR,R(ArgTypes...)> task_shared_state_type;
   #else
- typedef detail::task_object<FR,R()> task_object_type;
+ typedef detail::task_shared_state<FR,R()> task_shared_state_type;
   #endif
 #else
- typedef detail::task_object<FR,R> task_object_type;
+ typedef detail::task_shared_state<FR,R> task_shared_state_type;
 #endif
- typedef typename Allocator::template rebind<task_object_type>::other A2;
+ typedef typename Allocator::template rebind<task_shared_state_type>::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
- task = task_ptr(::new(a2.allocate(1)) task_object_type(boost::forward<F>(f)), D(a2, 1) );
+ task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(boost::forward<F>(f)), D(a2, 1) );
           future_obtained = false;
         }
 #else // ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
@@ -2928,18 +3180,18 @@
         {
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- typedef detail::task_object<F,R(ArgTypes...)> task_object_type;
+ typedef detail::task_shared_state<F,R(ArgTypes...)> task_shared_state_type;
   #else
- typedef detail::task_object<F,R()> task_object_type;
+ typedef detail::task_shared_state<F,R()> task_shared_state_type;
   #endif
 #else
- typedef detail::task_object<F,R> task_object_type;
+ typedef detail::task_shared_state<F,R> task_shared_state_type;
 #endif
- typedef typename Allocator::template rebind<task_object_type>::other A2;
+ typedef typename Allocator::template rebind<task_shared_state_type>::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
- task = task_ptr(::new(a2.allocate(1)) task_object_type(f), D(a2, 1) );
+ task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(f), D(a2, 1) );
           future_obtained = false;
         }
         template <class F, class Allocator>
@@ -2947,21 +3199,21 @@
         {
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- typedef detail::task_object<F,R(ArgTypes...)> task_object_type;
+ typedef detail::task_shared_state<F,R(ArgTypes...)> task_shared_state_type;
   #else
- typedef detail::task_object<F,R()> task_object_type;
+ typedef detail::task_shared_state<F,R()> task_shared_state_type;
   #endif
 #else
- typedef detail::task_object<F,R> task_object_type;
+ typedef detail::task_shared_state<F,R> task_shared_state_type;
 #endif
- typedef typename Allocator::template rebind<task_object_type>::other A2;
+ typedef typename Allocator::template rebind<task_shared_state_type>::other A2;
           A2 a2(a);
           typedef thread_detail::allocator_destructor<A2> D;
 
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- task = task_ptr(::new(a2.allocate(1)) task_object_type(boost::forward<F>(f)), D(a2, 1) );
+ task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(boost::forward<F>(f)), D(a2, 1) );
 #else
- task = task_ptr(::new(a2.allocate(1)) task_object_type(boost::move(f)), D(a2, 1) ); // TODO forward
+ task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(boost::move(f)), D(a2, 1) ); // TODO forward
 #endif
           future_obtained = false;
         }
@@ -3018,7 +3270,6 @@
         // result retrieval
         BOOST_THREAD_FUTURE<R> get_future()
         {
-
             if(!task)
             {
                 boost::throw_exception(task_moved());
@@ -3033,10 +3284,8 @@
                 boost::throw_exception(future_already_retrieved());
             }
             //return BOOST_THREAD_FUTURE<R>();
-
         }
 
-
         // execution
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
         void operator()(BOOST_THREAD_RV_REF(ArgTypes)... args)
@@ -3084,7 +3333,6 @@
         {
             task->set_wait_callback(f,this);
         }
-
     };
 
 #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
@@ -3101,26 +3349,26 @@
     namespace detail
     {
     ////////////////////////////////
- // make_future_deferred_object
+ // make_future_deferred_shared_state
     ////////////////////////////////
     template <class Rp, class Fp>
     BOOST_THREAD_FUTURE<Rp>
- make_future_deferred_object(BOOST_THREAD_FWD_REF(Fp) f)
+ make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f)
     {
- shared_ptr<future_deferred_object<Rp, Fp> >
- h(new future_deferred_object<Rp, Fp>(boost::forward<Fp>(f)));
+ shared_ptr<future_deferred_shared_state<Rp, Fp> >
+ h(new future_deferred_shared_state<Rp, Fp>(boost::forward<Fp>(f)));
       return BOOST_THREAD_FUTURE<Rp>(h);
     }
 
     ////////////////////////////////
- // make_future_async_object
+ // make_future_async_shared_state
     ////////////////////////////////
     template <class Rp, class Fp>
     BOOST_THREAD_FUTURE<Rp>
- make_future_async_object(BOOST_THREAD_FWD_REF(Fp) f)
+ make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f)
     {
- shared_ptr<future_async_object<Rp, Fp> >
- h(new future_async_object<Rp, Fp>(boost::forward<Fp>(f)));
+ shared_ptr<future_async_shared_state<Rp, Fp> >
+ h(new future_async_shared_state<Rp, Fp>(boost::forward<Fp>(f)));
       return BOOST_THREAD_FUTURE<Rp>(h);
     }
 
@@ -3159,7 +3407,7 @@
           if (int(policy) & int(launch::async))
             {
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_async_object<Rp>(
+ return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_async_shared_state<Rp>(
               BF(
                   thread_detail::decay_copy(boost::forward<F>(f))
                   , thread_detail::decay_copy(boost::forward<ArgTypes>(args))...
@@ -3177,7 +3425,7 @@
             else if (int(policy) & int(launch::deferred))
             {
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_deferred_object<Rp>(
+ return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_deferred_shared_state<Rp>(
               BF(
                   thread_detail::decay_copy(boost::forward<F>(f))
                   , thread_detail::decay_copy(boost::forward<ArgTypes>(args))...
@@ -3237,7 +3485,7 @@
         if (int(policy) & int(launch::async))
         {
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_async_object<Rp>(
+ return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_async_shared_state<Rp>(
               BF(
                   thread_detail::decay_copy(boost::forward<F>(f))
                   , thread_detail::decay_copy(boost::forward<ArgTypes>(args))...
@@ -3248,18 +3496,14 @@
 
           BOOST_THREAD_FUTURE<R> ret = pt.get_future();
           ret.set_async();
-//#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
-// boost::thread( boost::move(pt), boost::forward<ArgTypes>(args)... ).detach(); // todo forward
-//#else
           boost::thread( boost::move(pt) ).detach();
-//#endif
           return ::boost::move(ret);
 #endif
         }
         else if (int(policy) & int(launch::deferred))
         {
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_deferred_object<Rp>(
+ return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_deferred_shared_state<Rp>(
               BF(
                   thread_detail::decay_copy(boost::forward<F>(f))
                   , thread_detail::decay_copy(boost::forward<ArgTypes>(args))...
@@ -3269,7 +3513,7 @@
               std::terminate();
               BOOST_THREAD_FUTURE<R> ret;
               return ::boost::move(ret);
-// return boost::detail::make_future_deferred_object<Rp>(
+// return boost::detail::make_future_deferred_shared_state<Rp>(
 // BF(
 // thread_detail::decay_copy(boost::forward<F>(f))
 // )
@@ -3332,9 +3576,9 @@
   template <typename T>
   BOOST_THREAD_FUTURE<typename decay<T>::type> make_future(BOOST_THREAD_FWD_REF(T) value)
   {
- typedef typename decay<T>::type future_type;
- promise<future_type> p;
- p.set_value(boost::forward<T>(value));
+ typedef typename decay<T>::type future_value_type;
+ promise<future_value_type> p;
+ p.set_value(boost::forward<future_value_type>(value));
     return BOOST_THREAD_MAKE_RV_REF(p.get_future());
   }
 
@@ -3353,9 +3597,9 @@
   template <typename T>
   BOOST_THREAD_FUTURE<typename decay<T>::type> make_ready_future(BOOST_THREAD_FWD_REF(T) value)
   {
- typedef typename decay<T>::type future_type;
- promise<future_type> p;
- p.set_value(boost::forward<T>(value));
+ typedef typename decay<T>::type future_value_type;
+ promise<future_value_type> p;
+ p.set_value(boost::forward<future_value_type>(value));
     return BOOST_THREAD_MAKE_RV_REF(p.get_future());
   }
 
@@ -3368,21 +3612,25 @@
   }
 #endif
 
- ////////////////////////////////
- // make_exceptional_future
- ////////////////////////////////
   template <typename T>
- BOOST_THREAD_FUTURE<T> make_exceptional_future(exception_ptr ex)
+ BOOST_THREAD_FUTURE<T> make_ready_future(exception_ptr ex)
   {
     promise<T> p;
     p.set_exception(ex);
     return BOOST_THREAD_MAKE_RV_REF(p.get_future());
   }
+ template <typename T, typename E>
+ BOOST_THREAD_FUTURE<T> make_ready_future(E ex)
+ {
+ promise<T> p;
+ p.set_exception(boost::copy_exception(ex));
+ return BOOST_THREAD_MAKE_RV_REF(p.get_future());
+ }
 
 #if 0
   template<typename CLOSURE>
   make_future(CLOSURE closure) -> BOOST_THREAD_FUTURE<decltype(closure())> {
- typedef decltype(closure() T;
+ typedef decltype(closure()) T;
       promise<T> p;
       try
       {
@@ -3416,105 +3664,74 @@
 
   }
 
- ////////////////////////////////
- // make_ready_shared_future
- ////////////////////////////////
- template <typename T>
- shared_future<typename decay<T>::type> make_ready_shared_future(BOOST_THREAD_FWD_REF(T) value)
- {
- typedef typename decay<T>::type future_type;
- promise<future_type> p;
- p.set_value(boost::forward<T>(value));
- return p.get_future().share();
- }
-
-
- inline shared_future<void> make_ready_shared_future()
- {
- promise<void> p;
- return BOOST_THREAD_MAKE_RV_REF(p.get_future().share());
-
- }
-
- ////////////////////////////////
- // make_exceptional_shared_future
- ////////////////////////////////
- template <typename T>
- shared_future<T> make_exceptional_shared_future(exception_ptr ex)
- {
- promise<T> p;
- p.set_exception(ex);
- return p.get_future().share();
- }
+// ////////////////////////////////
+// // make_ready_shared_future
+// ////////////////////////////////
+// template <typename T>
+// shared_future<typename decay<T>::type> make_ready_shared_future(BOOST_THREAD_FWD_REF(T) value)
+// {
+// typedef typename decay<T>::type future_type;
+// promise<future_type> p;
+// p.set_value(boost::forward<T>(value));
+// return p.get_future().share();
+// }
+//
+//
+// inline shared_future<void> make_ready_shared_future()
+// {
+// promise<void> p;
+// return BOOST_THREAD_MAKE_RV_REF(p.get_future().share());
+//
+// }
+//
+// ////////////////////////////////
+// // make_exceptional_shared_future
+// ////////////////////////////////
+// template <typename T>
+// shared_future<T> make_exceptional_shared_future(exception_ptr ex)
+// {
+// promise<T> p;
+// p.set_exception(ex);
+// return p.get_future().share();
+// }
 
   ////////////////////////////////
- // detail::future_async_continuation
+ // detail::future_async_continuation_shared_state
   ////////////////////////////////
 #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
   namespace detail
   {
 
     /////////////////////////
- /// future_async_continuation
+ /// future_async_continuation_shared_state
     /////////////////////////
 
     template<typename F, typename Rp, typename Fp>
- struct future_async_continuation: future_object<Rp>
+ struct future_async_continuation_shared_state: future_async_shared_state_base<Rp>
     {
- typedef future_object<Rp> base_type;
- typedef typename base_type::move_dest_type move_dest_type;
- typedef weak_ptr<future_object_base> parent_ptr_type;
-
       F parent;
       Fp continuation;
- boost::thread thr_;
 
     public:
- future_async_continuation(
- F& f, BOOST_THREAD_FWD_REF(Fp) c
+ future_async_continuation_shared_state(
+ BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c
           ) :
- parent(f.future_),
- //continuation(boost::move(c)),
- continuation(c),
- thr_()
+ parent(boost::move(f)),
+ continuation(boost::move(c))
       {
- this->set_async();
- }
-
- ~future_async_continuation()
- {
- if (thr_.get_id()==thread::id())
- {
- //BOOST_THREAD_LOG << "ERRORRRRRRRRR ~future_async_continuation " << this << " " << thr_.get_id() << BOOST_THREAD_END_LOG;
- return;
- }
- if (thr_.joinable()) {
- thr_.join();
- }
       }
 
       void launch_continuation(boost::unique_lock<boost::mutex>& lock)
       {
         lock.unlock();
- thr_ = thread(&future_async_continuation::run, this);
+ this->thr_ = thread(&future_async_continuation_shared_state::run, this);
       }
 
- move_dest_type get()
- {
- if (thr_.joinable()) thr_.join();
- // fixme Is the lock needed during the whole scope?
- //this->wait();
- boost::unique_lock<boost::mutex> lock(this->mutex);
- this->wait_internal(lock);
-
- // fixme use boost::move
- return static_cast<move_dest_type>(*(this->result));
- }
- static void run(future_async_continuation* that)
+ static void run(future_async_continuation_shared_state* that)
       {
         try
         {
- that->mark_finished_with_result(that->continuation(that->parent));
+ that->mark_finished_with_result(that->continuation(boost::move(that->parent)));
         }
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
         catch(thread_interrupted& )
@@ -3530,44 +3747,31 @@
     };
 
     template<typename F, typename Fp>
- struct future_async_continuation<F, void, Fp>: public future_object<void>
+ struct future_async_continuation_shared_state<F, void, Fp>: public future_async_shared_state_base<void>
     {
- typedef future_object<void> base_type;
       F parent;
       Fp continuation;
- boost::thread thr_;
 
     public:
- future_async_continuation(
- F& f, BOOST_THREAD_FWD_REF(Fp) c
+ future_async_continuation_shared_state(
+ BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c
           ) :
- parent(f.future_),
- continuation(boost::move(c)),
- thr_()
- {
- this->set_async();
- }
-
- ~future_async_continuation()
+ parent(boost::move(f)),
+ continuation(boost::move(c))
       {
- if (thr_.get_id()==thread::id())
- {
- return;
- }
- if (thr_.joinable()) thr_.join();
       }
 
       void launch_continuation(boost::unique_lock<boost::mutex>& lk)
       {
         lk.unlock();
- thr_ = thread(&future_async_continuation::run, this);
+ this->thr_ = thread(&future_async_continuation_shared_state::run, this);
       }
 
- static void run(future_async_continuation* that)
+ static void run(future_async_continuation_shared_state* that)
       {
         try
         {
- that->continuation(that->parent);
+ that->continuation(boost::move(that->parent));
           that->mark_finished_with_result();
         }
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
@@ -3585,22 +3789,20 @@
 
 
     //////////////////////////
- /// future_deferred_continuation
+ /// future_deferred_continuation_shared_state
     //////////////////////////
     template<typename F, typename Rp, typename Fp>
- struct future_deferred_continuation: future_object<Rp>
+ struct future_deferred_continuation_shared_state: shared_state<Rp>
     {
- typedef future_object<Rp> base_type;
       F parent;
       Fp continuation;
 
     public:
- future_deferred_continuation(
- F& f, BOOST_THREAD_FWD_REF(Fp) c
+ future_deferred_continuation_shared_state(
+ BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c
           ) :
- parent(f.future_),
- //continuation(boost::move(c))
- continuation(c)
+ parent(boost::move(f)),
+ continuation(boost::move(c))
       {
         this->set_deferred();
       }
@@ -3613,7 +3815,7 @@
       virtual void execute(boost::unique_lock<boost::mutex>& lck) {
         try
         {
- this->mark_finished_with_result_internal(continuation(parent), lck);
+ this->mark_finished_with_result_internal(continuation(boost::move(parent)), lck);
         }
         catch (...)
         {
@@ -3623,17 +3825,16 @@
     };
 
     template<typename F, typename Fp>
- struct future_deferred_continuation<F,void,Fp>: future_object<void>
+ struct future_deferred_continuation_shared_state<F,void,Fp>: shared_state<void>
     {
- typedef future_object<void> base_type;
       F parent;
       Fp continuation;
 
     public:
- future_deferred_continuation(
- F& f, BOOST_THREAD_FWD_REF(Fp) c
+ future_deferred_continuation_shared_state(
+ BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c
           ):
- parent(f.future_),
+ parent(boost::move(f)),
           continuation(boost::move(c))
       {
         this->set_deferred();
@@ -3646,7 +3847,7 @@
       virtual void execute(boost::unique_lock<boost::mutex>& lck) {
         try
         {
- continuation(parent);
+ continuation(boost::move(parent));
           this->mark_finished_with_result_internal(lck);
         }
         catch (...)
@@ -3657,141 +3858,37 @@
     };
 
     ////////////////////////////////
- // make_future_deferred_continuation
+ // make_future_deferred_continuation_shared_state
     ////////////////////////////////
     template<typename F, typename Rp, typename Fp>
     BOOST_THREAD_FUTURE<Rp>
- make_future_deferred_continuation(
+ make_future_deferred_continuation_shared_state(
         boost::unique_lock<boost::mutex> &lock,
- F& f, BOOST_THREAD_FWD_REF(Fp) c
+ BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c
         )
     {
- shared_ptr<future_deferred_continuation<F, Rp, Fp> >
- h(new future_deferred_continuation<F, Rp, Fp>(f, boost::forward<Fp>(c)));
- f.future_->set_continuation_ptr(h, lock);
+ shared_ptr<future_deferred_continuation_shared_state<F, Rp, Fp> >
+ h(new future_deferred_continuation_shared_state<F, Rp, Fp>(boost::move(f), boost::forward<Fp>(c)));
+ h->parent.future_->set_continuation_ptr(h, lock);
       return BOOST_THREAD_FUTURE<Rp>(h);
     }
 
     ////////////////////////////////
- // make_future_async_continuation
+ // make_future_async_continuation_shared_state
     ////////////////////////////////
     template<typename F, typename Rp, typename Fp>
     BOOST_THREAD_FUTURE<Rp>
- make_future_async_continuation(
- boost::unique_lock<boost::mutex> &lock, F& f, BOOST_THREAD_FWD_REF(Fp) c
+ make_future_async_continuation_shared_state(
+ boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c
         )
     {
- shared_ptr<future_async_continuation<F,Rp, Fp> >
- h(new future_async_continuation<F,Rp, Fp>(f, boost::forward<Fp>(c)));
- f.future_->set_continuation_ptr(h, lock);
+ shared_ptr<future_async_continuation_shared_state<F,Rp, Fp> >
+ h(new future_async_continuation_shared_state<F,Rp, Fp>(boost::move(f), boost::forward<Fp>(c)));
+ h->parent.future_->set_continuation_ptr(h, lock);
 
       return BOOST_THREAD_FUTURE<Rp>(h);
     }
 
-// template <typename F, typename R, typename C>
-// struct future_continuation : future_object<R>
-// {
-// F& parent;
-// C continuation;
-// launch policy_;
-//
-// future_continuation(boost::unique_lock<boost::mutex>& lk, F& f, BOOST_THREAD_FWD_REF(C) c) :
-// parent(f),
-// continuation(boost::forward<C>(c)),
-// policy_(f.launch_policy())
-// {
-// init_continuation(lk);
-// }
-// future_continuation(boost::unique_lock<boost::mutex>& lk, F& f, BOOST_THREAD_FWD_REF(C) c, launch policy) :
-// parent(f),
-// continuation(boost::forward<C>(c)),
-// policy_(policy)
-// {
-// init_continuation(lk);
-// }
-// ~future_continuation()
-// {}
-//
-// void init_continuation(boost::unique_lock<boost::mutex>& lk)
-// {
-// try
-// {
-// lk.unlock();
-// // fixme what to do depending on inherits_launch_policy_ and policy_?
-// if (int(policy_) & int(launch::deferred))
-// {
-// R val = continuation(parent);
-// next.set_value(boost::move(val));
-// }
-// else
-// {
-// BOOST_THREAD_FUTURE<R> f = async(policy_, continuation, boost::ref(parent));
-// R val = f.get();
-// next.set_value(boost::move(val));
-// }
-// }
-// catch (...)
-// {
-// next.set_exception(boost::current_exception());
-// }
-// }
-// private:
-//
-// future_continuation(future_continuation const&);
-// future_continuation& operator=(future_continuation const&);
-// };
-//#if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR)
-// template <typename F, typename R, typename CR>
-// struct future_continuation<F,R,CR(*)(F&)> : future_object<R>
-// {
-// F& parent;
-// CR(*continuation)(F&) ;
-// launch policy_;
-//
-// future_continuation(F& f, CR(*c)(F&)) :
-// parent(f),
-// continuation(c),
-// policy_(f.launch_policy()),
-// next()
-// {}
-// future_continuation(F& f, CR(*c)(F&), launch policy) :
-// parent(f),
-// continuation(c),
-// policy_(policy),
-// next()
-// {}
-// ~future_continuation()
-// {}
-//
-// void start_continuation(boost::unique_lock<boost::mutex>& lk)
-// {
-// try
-// {
-// lk.unlock();
-// // fixme what to do depending on inherits_launch_policy_ and policy_?
-// if (int(policy_) & int(launch::deferred))
-// {
-// R val = continuation(parent);
-// next.set_value(boost::move(val));
-// }
-// else
-// {
-// BOOST_THREAD_FUTURE<R> f = async(policy_, continuation, boost::ref(parent));
-// R val = f.get();
-// next.set_value(boost::move(val));
-// }
-// }
-// catch (...)
-// {
-// next.set_exception(boost::current_exception());
-// }
-// }
-// private:
-//
-// future_continuation(future_continuation const&);
-// future_continuation& operator=(future_continuation const&);
-// };
-//#endif
   }
 
   ////////////////////////////////
@@ -3801,74 +3898,69 @@
 
   template <typename R>
   template <typename F>
- inline BOOST_THREAD_FUTURE<typename boost::result_of<F(BOOST_THREAD_FUTURE<R>&)>::type>
+ inline BOOST_THREAD_FUTURE<typename boost::result_of<F(BOOST_THREAD_FUTURE<R>)>::type>
   BOOST_THREAD_FUTURE<R>::then(launch policy, BOOST_THREAD_FWD_REF(F) func)
   {
 
- typedef typename boost::result_of<F(BOOST_THREAD_FUTURE<R>&)>::type future_type;
-
- if (this->future_==0)
- {
- // fixme what to do when the future has no associated state?
- return BOOST_THREAD_FUTURE<future_type>();
- }
+ typedef typename boost::result_of<F(BOOST_THREAD_FUTURE<R>)>::type future_type;
+ BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized());
 
- boost::unique_lock<boost::mutex> lock(this->future_->mutex);
- if (int(policy) & int(launch::async))
+ boost::unique_lock<boost::mutex> lock(this->future_->mutex);
+ if (int(policy) & int(launch::async))
     {
- return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation<BOOST_THREAD_FUTURE<R>, future_type, F>(
- lock, *this, boost::forward<F>(func)
- )));
+ return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
+ )));
+ }
+ else if (int(policy) & int(launch::deferred))
+ {
+ return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
+ )));
+ }
+ else
+ {
+ //BOOST_THREAD_ASSERT_PRECONDITION(false && "invalid launch parameter", std::logic_error("invalid launch parameter"));
+ return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
+ )));
+
     }
- else
- if (int(policy) & int(launch::deferred))
- {
- return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation<BOOST_THREAD_FUTURE<R>, future_type, F>(
- lock, *this, boost::forward<F>(func)
- )));
- }
- else
- {
- // fixme what to do when the policy is invalid?
- return BOOST_THREAD_FUTURE<future_type>();
- }
 
   }
   template <typename R>
   template <typename F>
- inline BOOST_THREAD_FUTURE<typename boost::result_of<F(BOOST_THREAD_FUTURE<R>&)>::type>
+ inline BOOST_THREAD_FUTURE<typename boost::result_of<F(BOOST_THREAD_FUTURE<R>)>::type>
   BOOST_THREAD_FUTURE<R>::then(BOOST_THREAD_FWD_REF(F) func)
   {
 
- typedef typename boost::result_of<F(BOOST_THREAD_FUTURE<R>&)>::type future_type;
-
- if (this->future_==0)
- {
- //BOOST_THREAD_LOG << "ERROR future::then " << this << BOOST_THREAD_END_LOG;
- // fixme what to do when the future has no associated state?
- return BOOST_THREAD_FUTURE<future_type>();
- }
+ typedef typename boost::result_of<F(BOOST_THREAD_FUTURE<R>)>::type future_type;
+ BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized());
 
     boost::unique_lock<boost::mutex> lock(this->future_->mutex);
     if (int(this->launch_policy()) & int(launch::async))
     {
- return boost::detail::make_future_async_continuation<BOOST_THREAD_FUTURE<R>, future_type, F>(
- lock, *this, boost::forward<F>(func)
+ return boost::detail::make_future_async_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
       );
     }
     else if (int(this->launch_policy()) & int(launch::deferred))
     {
       this->future_->wait_internal(lock);
- return boost::detail::make_future_deferred_continuation<BOOST_THREAD_FUTURE<R>, future_type, F>(
- lock, *this, boost::forward<F>(func)
+ return boost::detail::make_future_deferred_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
       );
     }
     else
     {
- // fixme what to do when the policy is invalid?
- return BOOST_THREAD_FUTURE<future_type>();
+ //BOOST_THREAD_ASSERT_PRECONDITION(false && "invalid launch parameter", std::logic_error("invalid launch parameter"));
+ return boost::detail::make_future_async_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
+ );
     }
   }
+
+
 //#if 0 && defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR)
 // template <typename R>
 // template<typename RF>
@@ -3922,8 +4014,184 @@
 // }
 //#endif
 
+ template <typename R>
+ template <typename F>
+ inline BOOST_THREAD_FUTURE<typename boost::result_of<F(shared_future<R>)>::type>
+ shared_future<R>::then(launch policy, BOOST_THREAD_FWD_REF(F) func)
+ {
+
+ typedef typename boost::result_of<F(shared_future<R>)>::type future_type;
+ BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized());
+
+ boost::unique_lock<boost::mutex> lock(this->future_->mutex);
+ if (int(policy) & int(launch::async))
+ {
+ return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state<shared_future<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
+ )));
+ }
+ else if (int(policy) & int(launch::deferred))
+ {
+ return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state<shared_future<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
+ )));
+ }
+ else
+ {
+ //BOOST_THREAD_ASSERT_PRECONDITION(false && "invalid launch parameter", std::logic_error("invalid launch parameter"));
+ return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state<shared_future<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
+ )));
+ }
+
+ }
+ template <typename R>
+ template <typename F>
+ inline BOOST_THREAD_FUTURE<typename boost::result_of<F(shared_future<R>)>::type>
+ shared_future<R>::then(BOOST_THREAD_FWD_REF(F) func)
+ {
+
+ typedef typename boost::result_of<F(shared_future<R>)>::type future_type;
+
+ BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized());
+
+ boost::unique_lock<boost::mutex> lock(this->future_->mutex);
+ if (int(this->launch_policy()) & int(launch::async))
+ {
+ return boost::detail::make_future_async_continuation_shared_state<shared_future<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
+ );
+ }
+ else if (int(this->launch_policy()) & int(launch::deferred))
+ {
+ this->future_->wait_internal(lock);
+ return boost::detail::make_future_deferred_continuation_shared_state<shared_future<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
+ );
+ }
+ else
+ {
+ //BOOST_THREAD_ASSERT_PRECONDITION(false && "invalid launch parameter", std::logic_error("invalid launch parameter"));
+ return boost::detail::make_future_async_continuation_shared_state<shared_future<R>, future_type, F>(
+ lock, boost::move(*this), boost::forward<F>(func)
+ );
+ }
+ }
+ namespace detail
+ {
+ template <typename T>
+ struct mfallbacker_to
+ {
+ T value_;
+ typedef T result_type;
+ mfallbacker_to(BOOST_THREAD_RV_REF(T) v)
+ : value_(boost::move(v))
+ {}
+
+ T operator()(BOOST_THREAD_FUTURE<T> fut)
+ {
+ return fut.get_or(boost::move(value_));
+
+ }
+ };
+ template <typename T>
+ struct cfallbacker_to
+ {
+ T value_;
+ typedef T result_type;
+ cfallbacker_to(T const& v)
+ : value_(v)
+ {}
+
+ T operator()(BOOST_THREAD_FUTURE<T> fut)
+ {
+ return fut.get_or(value_);
+
+ }
+ };
+ }
+ ////////////////////////////////
+ // future<R> future<R>::fallback_to(R&& v);
+ ////////////////////////////////
+
+ template <typename R>
+ template <typename R2>
+ inline typename disable_if< is_void<R2>, BOOST_THREAD_FUTURE<R> >::type
+ BOOST_THREAD_FUTURE<R>::fallback_to(BOOST_THREAD_RV_REF(R2) v)
+ {
+ return then(detail::mfallbacker_to<R>(boost::move(v)));
+ }
+
+ template <typename R>
+ template <typename R2>
+ inline typename disable_if< is_void<R2>, BOOST_THREAD_FUTURE<R> >::type
+ BOOST_THREAD_FUTURE<R>::fallback_to(R2 const& v)
+ {
+ return then(detail::cfallbacker_to<R>(v));
+ }
+
 #endif
 
+#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
+ namespace detail
+ {
+
+ /////////////////////////
+ /// future_unwrap_shared_state
+ /////////////////////////
+
+ template<typename F, typename Rp>
+ struct future_unwrap_shared_state: shared_state<Rp>
+ {
+ F parent;
+ public:
+ explicit future_unwrap_shared_state(
+ BOOST_THREAD_RV_REF(F) f
+ ) :
+ parent(boost::move(f))
+ {
+ }
+ virtual void wait(bool ) // todo see if rethrow must be used
+ {
+ boost::unique_lock<boost::mutex> lock(mutex);
+ parent.get().wait();
+ }
+ virtual Rp get()
+ {
+ boost::unique_lock<boost::mutex> lock(mutex);
+ return parent.get().get();
+ }
+
+ };
+
+ template <class F, class Rp>
+ BOOST_THREAD_FUTURE<Rp>
+ make_future_unwrap_shared_state(boost::unique_lock<boost::mutex> &lock, BOOST_THREAD_RV_REF(F) f)
+ {
+ shared_ptr<future_unwrap_shared_state<F, Rp> >
+ //shared_ptr<basic_future<Rp> >
+ //typename boost::detail::basic_future<Rp>::future_ptr
+ h(new future_unwrap_shared_state<F, Rp>(boost::move(f)));
+ h->parent.future_->set_continuation_ptr(h, lock);
+ return BOOST_THREAD_FUTURE<Rp>(h);
+ }
+ }
+
+ template <typename R>
+ inline BOOST_THREAD_FUTURE<R>::BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE<BOOST_THREAD_FUTURE<R> >) other):
+ base_type(other.unwrap())
+ {
+ }
+
+ template <typename R2>
+ BOOST_THREAD_FUTURE<R2>
+ BOOST_THREAD_FUTURE<BOOST_THREAD_FUTURE<R2> >::unwrap()
+ {
+ BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized());
+ boost::unique_lock<boost::mutex> lock(this->future_->mutex);
+ return boost::detail::make_future_unwrap_shared_state<BOOST_THREAD_FUTURE<BOOST_THREAD_FUTURE<R2> >, R2>(lock, boost::move(*this));
+ }
+#endif
 }
 
 #endif // BOOST_NO_EXCEPTION

Modified: branches/release/boost/thread/latch.hpp
==============================================================================
--- branches/release/boost/thread/latch.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/latch.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -23,28 +23,40 @@
 {
   class latch
   {
- /// @Requires: count_.value_ must be greater than 0
- /// Effect: Decrement the count. Unlocks the lock notify anyone waiting if we reached zero.
- /// Returns: true if count_.value_ reached the value 0.
+ /// @Requires: count_ must be greater than 0
+ /// Effect: Decrement the count. Unlocks the lock and notify anyone waiting if we reached zero.
+ /// Returns: true if count_ reached the value 0.
     /// @ThreadSafe ensured by the @c lk parameter
     bool count_down(unique_lock<mutex> &lk)
- /// pre_condition (count_.value_ > 0)
+ /// pre_condition (count_ > 0)
     {
- BOOST_ASSERT(count_.value_ > 0);
- if (--count_.value_ == 0)
+ BOOST_ASSERT(count_ > 0);
+ if (--count_ == 0)
       {
- count_.cond_.notify_all();
+ ++generation_;
         lk.unlock();
+ cond_.notify_all();
         return true;
       }
       return false;
     }
+ /// Effect: Decrement the count is > 0. Unlocks the lock notify anyone waiting if we reached zero.
+ /// Returns: true if count_ is 0.
+ /// @ThreadSafe ensured by the @c lk parameter
+ bool try_count_down(unique_lock<mutex> &lk)
+ {
+ if (count_ > 0)
+ {
+ return count_down(lk);
+ }
+ return true;
+ }
   public:
     BOOST_THREAD_NO_COPYABLE( latch)
 
     /// Constructs a latch with a given count.
     latch(std::size_t count) :
- count_(count)
+ count_(count), generation_(0)
     {
     }
 
@@ -60,7 +72,8 @@
     void wait()
     {
       boost::unique_lock<boost::mutex> lk(mutex_);
- count_.cond_.wait(lk, detail::counter_is_zero(count_));
+ std::size_t generation(generation_);
+ cond_.wait(lk, detail::not_equal(generation, generation_));
     }
 
     /// @return true if the internal counter is already 0, false otherwise
@@ -76,7 +89,8 @@
     cv_status wait_for(const chrono::duration<Rep, Period>& rel_time)
     {
       boost::unique_lock<boost::mutex> lk(mutex_);
- return count_.cond_.wait_for(lk, rel_time, detail::counter_is_zero(count_))
+ std::size_t generation(generation_);
+ return cond_.wait_for(lk, rel_time, detail::not_equal(generation, generation_))
               ? cv_status::no_timeout
               : cv_status::timeout;
     }
@@ -87,7 +101,8 @@
     cv_status wait_until(const chrono::time_point<Clock, Duration>& abs_time)
     {
       boost::unique_lock<boost::mutex> lk(mutex_);
- return count_.cond_.wait_until(lk, abs_time, detail::counter_is_zero(count_))
+ std::size_t generation(generation_);
+ return cond_.wait_until(lk, abs_time, detail::not_equal(generation, generation_))
           ? cv_status::no_timeout
           : cv_status::timeout;
     }
@@ -99,6 +114,13 @@
       boost::unique_lock<boost::mutex> lk(mutex_);
       count_down(lk);
     }
+ /// Effect: Decrement the count if it is > 0 and notify anyone waiting if we reached zero.
+ /// Returns: true if count_ was 0 or reached 0.
+ bool try_count_down()
+ {
+ boost::unique_lock<boost::mutex> lk(mutex_);
+ return try_count_down(lk);
+ }
     void signal()
     {
       count_down();
@@ -110,11 +132,12 @@
     void count_down_and_wait()
     {
       boost::unique_lock<boost::mutex> lk(mutex_);
+ std::size_t generation(generation_);
       if (count_down(lk))
       {
         return;
       }
- count_.cond_.wait(lk, detail::counter_is_zero(count_));
+ cond_.wait(lk, detail::not_equal(generation, generation_));
     }
     void sync()
     {
@@ -132,7 +155,9 @@
 
   private:
     mutex mutex_;
- detail::counter count_;
+ condition_variable cond_;
+ std::size_t count_;
+ std::size_t generation_;
   };
 
 } // namespace boost

Modified: branches/release/boost/thread/pthread/thread_data.hpp
==============================================================================
--- branches/release/boost/thread/pthread/thread_data.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/pthread/thread_data.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -82,7 +82,7 @@
 
     namespace detail
     {
- struct future_object_base;
+ struct shared_state_base;
         struct tss_cleanup_function;
         struct thread_exit_callback_node;
         struct tss_data_node
@@ -121,7 +121,7 @@
> notify_list_t;
             notify_list_t notify;
 
- typedef std::vector<shared_ptr<future_object_base> > async_states_t;
+ typedef std::vector<shared_ptr<shared_state_base> > async_states_t;
             async_states_t async_states_;
 
 //#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
@@ -154,7 +154,7 @@
               notify.push_back(std::pair<condition_variable*, mutex*>(cv, m));
             }
 
- void make_ready_at_thread_exit(shared_ptr<future_object_base> as)
+ void make_ready_at_thread_exit(shared_ptr<shared_state_base> as)
             {
               async_states_.push_back(as);
             }

Modified: branches/release/boost/thread/sync_bounded_queue.hpp
==============================================================================
--- branches/release/boost/thread/sync_bounded_queue.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/sync_bounded_queue.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -48,31 +48,31 @@
     ~sync_bounded_queue();
 
     // Observers
- bool empty() const;
- bool full() const;
- size_type capacity() const;
- size_type size() const;
- bool closed() const;
+ inline bool empty() const;
+ inline bool full() const;
+ inline size_type capacity() const;
+ inline size_type size() const;
+ inline bool closed() const;
 
     // Modifiers
- void close();
+ inline void close();
 
- void push(const value_type& x);
- void push(BOOST_THREAD_RV_REF(value_type) x);
- bool try_push(const value_type& x);
- bool try_push(BOOST_THREAD_RV_REF(value_type) x);
- bool try_push(no_block_tag, const value_type& x);
- bool try_push(no_block_tag, BOOST_THREAD_RV_REF(value_type) x);
+ inline void push(const value_type& x);
+ inline void push(BOOST_THREAD_RV_REF(value_type) x);
+ inline bool try_push(const value_type& x);
+ inline bool try_push(BOOST_THREAD_RV_REF(value_type) x);
+ inline bool try_push(no_block_tag, const value_type& x);
+ inline bool try_push(no_block_tag, BOOST_THREAD_RV_REF(value_type) x);
 
     // Observers/Modifiers
- void pull(value_type&);
- void pull(ValueType& elem, bool & closed);
+ inline void pull(value_type&);
+ inline void pull(ValueType& elem, bool & closed);
     // enable_if is_nothrow_copy_movable<value_type>
- value_type pull();
- shared_ptr<ValueType> ptr_pull();
- bool try_pull(value_type&);
- bool try_pull(no_block_tag,value_type&);
- shared_ptr<ValueType> try_pull();
+ inline value_type pull();
+ inline shared_ptr<ValueType> ptr_pull();
+ inline bool try_pull(value_type&);
+ inline bool try_pull(no_block_tag,value_type&);
+ inline shared_ptr<ValueType> try_pull();
 
   private:
     mutable mutex mtx_;
@@ -86,42 +86,51 @@
     size_type capacity_;
     bool closed_;
 
- size_type inc(size_type idx) const BOOST_NOEXCEPT
+ inline size_type inc(size_type idx) const BOOST_NOEXCEPT
     {
       return (idx + 1) % capacity_;
     }
 
- bool empty(unique_lock<mutex>& ) const BOOST_NOEXCEPT
+ inline bool empty(unique_lock<mutex>& ) const BOOST_NOEXCEPT
     {
       return in_ == out_;
     }
- bool empty(lock_guard<mutex>& ) const BOOST_NOEXCEPT
+ inline bool empty(lock_guard<mutex>& ) const BOOST_NOEXCEPT
     {
       return in_ == out_;
     }
- size_type capacity(lock_guard<mutex>& ) const BOOST_NOEXCEPT
+ inline bool full(unique_lock<mutex>& ) const BOOST_NOEXCEPT
     {
- return capacity;
+ return (inc(in_) == out_);
     }
- size_type size(lock_guard<mutex>& ) const BOOST_NOEXCEPT
+ inline bool full(lock_guard<mutex>& ) const BOOST_NOEXCEPT
     {
- return ((out_+capacity_-in_) % capacity_)-1;
+ return (inc(in_) == out_);
+ }
+ inline size_type capacity(lock_guard<mutex>& ) const BOOST_NOEXCEPT
+ {
+ return capacity_-1;
+ }
+ inline size_type size(lock_guard<mutex>& lk) const BOOST_NOEXCEPT
+ {
+ if (full(lk)) return capacity(lk);
+ return ((out_+capacity(lk)-in_) % capacity(lk));
     }
 
- void throw_if_closed(unique_lock<mutex>&);
+ inline void throw_if_closed(unique_lock<mutex>&);
 
- bool try_pull(value_type& x, unique_lock<mutex>& lk);
- bool try_push(const value_type& x, unique_lock<mutex>& lk);
- bool try_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
- shared_ptr<value_type> try_pull(unique_lock<mutex>& lk);
+ inline bool try_pull(value_type& x, unique_lock<mutex>& lk);
+ inline bool try_push(const value_type& x, unique_lock<mutex>& lk);
+ inline bool try_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
+ inline shared_ptr<value_type> try_pull(unique_lock<mutex>& lk);
 
- void wait_until_not_empty(unique_lock<mutex>& lk);
- void wait_until_not_empty(unique_lock<mutex>& lk, bool&);
- size_type wait_until_not_full(unique_lock<mutex>& lk);
- size_type wait_until_not_full(unique_lock<mutex>& lk, bool&);
+ inline void wait_until_not_empty(unique_lock<mutex>& lk);
+ inline void wait_until_not_empty(unique_lock<mutex>& lk, bool&);
+ inline size_type wait_until_not_full(unique_lock<mutex>& lk);
+ inline size_type wait_until_not_full(unique_lock<mutex>& lk, bool&);
 
 
- void notify_not_empty_if_needed(unique_lock<mutex>& lk)
+ inline void notify_not_empty_if_needed(unique_lock<mutex>& lk)
     {
       if (waiting_empty_ > 0)
       {
@@ -130,7 +139,7 @@
         not_empty_.notify_one();
       }
     }
- void notify_not_full_if_needed(unique_lock<mutex>& lk)
+ inline void notify_not_full_if_needed(unique_lock<mutex>& lk)
     {
       if (waiting_full_ > 0)
       {
@@ -140,13 +149,13 @@
       }
     }
 
- void pull(value_type& elem, unique_lock<mutex>& lk)
+ inline void pull(value_type& elem, unique_lock<mutex>& lk)
     {
       elem = boost::move(data_[out_]);
       out_ = inc(out_);
       notify_not_full_if_needed(lk);
     }
- boost::shared_ptr<value_type> ptr_pull(unique_lock<mutex>& lk)
+ inline boost::shared_ptr<value_type> ptr_pull(unique_lock<mutex>& lk)
     {
       shared_ptr<value_type> res = make_shared<value_type>(boost::move(data_[out_]));
       out_ = inc(out_);
@@ -154,26 +163,23 @@
       return res;
     }
 
-
- void set_in(size_type in, unique_lock<mutex>& lk)
+ inline void set_in(size_type in, unique_lock<mutex>& lk)
     {
       in_ = in;
       notify_not_empty_if_needed(lk);
     }
 
- void push_at(const value_type& elem, size_type in_p_1, unique_lock<mutex>& lk)
+ inline void push_at(const value_type& elem, size_type in_p_1, unique_lock<mutex>& lk)
     {
       data_[in_] = elem;
       set_in(in_p_1, lk);
     }
 
- void push_at(BOOST_THREAD_RV_REF(value_type) elem, size_type in_p_1, unique_lock<mutex>& lk)
+ inline void push_at(BOOST_THREAD_RV_REF(value_type) elem, size_type in_p_1, unique_lock<mutex>& lk)
     {
       data_[in_] = boost::move(elem);
       set_in(in_p_1, lk);
     }
-
-
   };
 
   template <typename ValueType>

Modified: branches/release/boost/thread/sync_queue.hpp
==============================================================================
--- branches/release/boost/thread/sync_queue.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/sync_queue.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -37,37 +37,36 @@
 
     // Constructors/Assignment/Destructors
     BOOST_THREAD_NO_COPYABLE(sync_queue)
- sync_queue();
- template <typename Range>
- explicit sync_queue(Range range);
- ~sync_queue();
+ inline sync_queue();
+ //template <typename Range>
+ //inline explicit sync_queue(Range range);
+ inline ~sync_queue();
 
     // Observers
- bool empty() const;
- bool full() const;
- size_type size() const;
- bool closed() const;
+ inline bool empty() const;
+ inline bool full() const;
+ inline size_type size() const;
+ inline bool closed() const;
 
     // Modifiers
- void close();
+ inline void close();
 
- void push(const value_type& x);
- void push(BOOST_THREAD_RV_REF(value_type) x);
- bool try_push(const value_type& x);
- bool try_push(BOOST_THREAD_RV_REF(value_type) x);
- bool try_push(no_block_tag, const value_type& x);
- bool try_push(no_block_tag, BOOST_THREAD_RV_REF(value_type) x);
+ inline void push(const value_type& x);
+ inline void push(BOOST_THREAD_RV_REF(value_type) x);
+ inline bool try_push(const value_type& x);
+ inline bool try_push(BOOST_THREAD_RV_REF(value_type) x);
+ inline bool try_push(no_block_tag, const value_type& x);
+ inline bool try_push(no_block_tag, BOOST_THREAD_RV_REF(value_type) x);
 
     // Observers/Modifiers
- void pull(value_type&);
- void pull(ValueType& elem, bool & closed);
+ inline void pull(value_type&);
+ inline void pull(ValueType& elem, bool & closed);
     // enable_if is_nothrow_copy_movable<value_type>
- value_type pull();
- shared_ptr<ValueType> ptr_pull();
- bool try_pull(value_type&);
- bool try_pull(no_block_tag,value_type&);
- shared_ptr<ValueType> try_pull();
-
+ inline value_type pull();
+ inline shared_ptr<ValueType> ptr_pull();
+ inline bool try_pull(value_type&);
+ inline bool try_pull(no_block_tag,value_type&);
+ inline shared_ptr<ValueType> try_pull();
 
   private:
     mutable mutex mtx_;
@@ -76,32 +75,31 @@
     boost::container::deque<ValueType> data_;
     bool closed_;
 
- bool empty(unique_lock<mutex>& ) const BOOST_NOEXCEPT
+ inline bool empty(unique_lock<mutex>& ) const BOOST_NOEXCEPT
     {
       return data_.empty();
     }
- bool empty(lock_guard<mutex>& ) const BOOST_NOEXCEPT
+ inline bool empty(lock_guard<mutex>& ) const BOOST_NOEXCEPT
     {
       return data_.empty();
     }
 
- size_type size(lock_guard<mutex>& ) const BOOST_NOEXCEPT
+ inline size_type size(lock_guard<mutex>& ) const BOOST_NOEXCEPT
     {
       return data_.size();
     }
 
- void throw_if_closed(unique_lock<mutex>&);
-
- bool try_pull(value_type& x, unique_lock<mutex>& lk);
- bool try_push(const value_type& x, unique_lock<mutex>& lk);
- bool try_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
- shared_ptr<value_type> try_pull(unique_lock<mutex>& lk);
+ inline void throw_if_closed(unique_lock<mutex>&);
 
- void wait_until_not_empty(unique_lock<mutex>& lk);
- void wait_until_not_empty(unique_lock<mutex>& lk, bool&);
+ inline bool try_pull(value_type& x, unique_lock<mutex>& lk);
+ inline bool try_push(const value_type& x, unique_lock<mutex>& lk);
+ inline bool try_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
+ inline shared_ptr<value_type> try_pull(unique_lock<mutex>& lk);
 
+ inline void wait_until_not_empty(unique_lock<mutex>& lk);
+ inline void wait_until_not_empty(unique_lock<mutex>& lk, bool&);
 
- void notify_not_empty_if_needed(unique_lock<mutex>& lk)
+ inline void notify_not_empty_if_needed(unique_lock<mutex>& lk)
     {
       if (waiting_empty_ > 0)
       {
@@ -111,31 +109,29 @@
       }
     }
 
- void pull(value_type& elem, unique_lock<mutex>& )
+ inline void pull(value_type& elem, unique_lock<mutex>& )
     {
       elem = boost::move(data_.front());
       data_.pop_front();
     }
- boost::shared_ptr<value_type> ptr_pull(unique_lock<mutex>& )
+ inline boost::shared_ptr<value_type> ptr_pull(unique_lock<mutex>& )
     {
       shared_ptr<value_type> res = make_shared<value_type>(boost::move(data_.front()));
       data_.pop_front();
       return res;
     }
 
- void push(const value_type& elem, unique_lock<mutex>& lk)
+ inline void push(const value_type& elem, unique_lock<mutex>& lk)
     {
       data_.push_back(elem);
       notify_not_empty_if_needed(lk);
     }
 
- void push(BOOST_THREAD_RV_REF(value_type) elem, unique_lock<mutex>& lk)
+ inline void push(BOOST_THREAD_RV_REF(value_type) elem, unique_lock<mutex>& lk)
     {
       data_.push(boost::move(elem));
       notify_not_empty_if_needed(lk);
     }
-
-
   };
 
   template <typename ValueType>
@@ -309,6 +305,7 @@
       ++waiting_empty_;
       not_empty_.wait(lk);
     }
+ closed=false;
   }
 
   template <typename ValueType>

Modified: branches/release/boost/thread/testable_mutex.hpp
==============================================================================
--- branches/release/boost/thread/testable_mutex.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/testable_mutex.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -48,6 +48,7 @@
 
     void lock()
     {
+ BOOST_ASSERT(! is_locked_by_this_thread());
       mtx_.lock();
       id_ = this_thread::get_id();
     }
@@ -61,6 +62,7 @@
 
     bool try_lock()
     {
+ BOOST_ASSERT(! is_locked_by_this_thread());
       if (mtx_.try_lock())
       {
         id_ = this_thread::get_id();
@@ -75,6 +77,7 @@
     template <class Rep, class Period>
     bool try_lock_for(const chrono::duration<Rep, Period>& rel_time)
     {
+ BOOST_ASSERT(! is_locked_by_this_thread());
       if (mtx_.try_lock_for(rel_time))
       {
         id_ = this_thread::get_id();
@@ -88,6 +91,7 @@
     template <class Clock, class Duration>
     bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time)
     {
+ BOOST_ASSERT(! is_locked_by_this_thread());
       if (mtx_.try_lock_until(abs_time))
       {
         id_ = this_thread::get_id();

Modified: branches/release/boost/thread/v2/shared_mutex.hpp
==============================================================================
--- branches/release/boost/thread/v2/shared_mutex.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/v2/shared_mutex.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -179,15 +179,15 @@
       BOOST_THREAD_INLINE shared_mutex();
       BOOST_THREAD_INLINE ~shared_mutex();
 
-#ifndef BOOST_NO_DELETED_FUNCTIONS
+#ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
       shared_mutex(shared_mutex const&) = delete;
       shared_mutex& operator=(shared_mutex const&) = delete;
-#else // BOOST_NO_DELETED_FUNCTIONS
+#else // BOOST_NO_CXX11_DELETED_FUNCTIONS
     private:
       shared_mutex(shared_mutex const&);
       shared_mutex& operator=(shared_mutex const&);
     public:
-#endif // BOOST_NO_DELETED_FUNCTIONS
+#endif // BOOST_NO_CXX11_DELETED_FUNCTIONS
 
       // Exclusive ownership
 
@@ -381,15 +381,15 @@
       BOOST_THREAD_INLINE upgrade_mutex();
       BOOST_THREAD_INLINE ~upgrade_mutex();
 
-#ifndef BOOST_NO_DELETED_FUNCTIONS
+#ifndef BOOST_CXX11_NO_DELETED_FUNCTIONS
       upgrade_mutex(const upgrade_mutex&) = delete;
       upgrade_mutex& operator=(const upgrade_mutex&) = delete;
-#else // BOOST_NO_DELETED_FUNCTIONS
+#else // BOOST_CXX11_NO_DELETED_FUNCTIONS
     private:
       upgrade_mutex(const upgrade_mutex&);
       upgrade_mutex& operator=(const upgrade_mutex&);
     public:
-#endif // BOOST_NO_DELETED_FUNCTIONS
+#endif // BOOST_CXX11_NO_DELETED_FUNCTIONS
 
       // Exclusive ownership
 

Modified: branches/release/boost/thread/win32/thread_data.hpp
==============================================================================
--- branches/release/boost/thread/win32/thread_data.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/win32/thread_data.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -72,7 +72,7 @@
 
     namespace detail
     {
- struct future_object_base;
+ struct shared_state_base;
         struct tss_cleanup_function;
         struct thread_exit_callback_node;
         struct tss_data_node
@@ -102,7 +102,7 @@
> notify_list_t;
             notify_list_t notify;
 
- typedef std::vector<shared_ptr<future_object_base> > async_states_t;
+ typedef std::vector<shared_ptr<shared_state_base> > async_states_t;
             async_states_t async_states_;
 //#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
             // These data must be at the end so that the access to the other fields doesn't change
@@ -153,7 +153,7 @@
               notify.push_back(std::pair<condition_variable*, mutex*>(cv, m));
             }
 
- void make_ready_at_thread_exit(shared_ptr<future_object_base> as)
+ void make_ready_at_thread_exit(shared_ptr<shared_state_base> as)
             {
               async_states_.push_back(as);
             }

Modified: branches/release/boost/thread/win32/thread_primitives.hpp
==============================================================================
--- branches/release/boost/thread/win32/thread_primitives.hpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/boost/thread/win32/thread_primitives.hpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -19,7 +19,7 @@
 
 #ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
 #if _WIN32_WINNT >= 0x0600
-#define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
+//#define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
 #endif
 #endif
 

Modified: branches/release/libs/thread/doc/barrier.qbk
==============================================================================
--- branches/release/libs/thread/doc/barrier.qbk Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/doc/barrier.qbk 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -1,11 +1,12 @@
 [/
   (C) Copyright 2007-8 Anthony Williams.
+ (C) Copyright 2013 Vicente J. Botet Escriba.
   Distributed under the Boost Software License, Version 1.0.
   (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 ]
 
-[section:barriers Barriers]
+[section:barriers Barriers -- EXTENSION]
 
 A barrier is a simple concept. Also known as a ['rendezvous], it is a synchronization point between multiple threads. The barrier is
 configured for a particular number of threads (`n`), and as threads reach the barrier they must wait until all `n` threads have
@@ -22,14 +23,18 @@
         barrier& operator=(barrier const&) = delete;
 
         barrier(unsigned int count);
+ template <typename F>
+ barrier(unsigned int count, F&&);
+
         ~barrier();
 
         bool wait();
+ void count_down_and_wait();
     };
 
 Instances of __barrier__ are not copyable or movable.
 
-[heading Constructor]
+[section Constructor `barrier(unsigned int)`]
 
     barrier(unsigned int count);
 
@@ -41,7 +46,24 @@
 
 ]
 
-[heading Destructor]
+[endsect]
+[section Constructor `barrier(unsigned int, F&&)`]
+
+ barrier(unsigned int count, F&& completion);
+
+[variablelist
+
+[[Requires:] [The result type of the completion function call `completion()` is `void` or `unsigned int`.]]
+
+[[Effects:] [Construct a barrier for `count` threads and a completion function `completion`.]]
+
+[[Throws:] [__thread_resource_error__ if an error occurs.]]
+
+]
+
+
+[endsect]
+[section Destructor `~barrier()`]
 
     ~barrier();
 
@@ -55,24 +77,55 @@
 
 ]
 
-[heading Member function `wait`]
+[endsect]
+[section Member Function `wait()`]
 
     bool wait();
 
 [variablelist
 
-[[Effects:] [Block until `count` threads have called `wait` on `*this`. When the `count`-th thread calls `wait`, all waiting threads
-are unblocked, and the barrier is reset. ]]
+[[Effects:] [Block until `count` threads have called `wait` or `count_down_and_wait` on `*this`. When the `count`-th thread calls `wait`, the barrier is reset and all waiting threads are unblocked.
+The reset depends on whether the barrier was constructed with a completion function or not. If there is no completion function or if the completion function result is void, the reset consists in restoring the original count. Otherwise the rest consist in assigning the result of the completion function (which must not be 0).]]
 
 [[Returns:] [`true` for exactly one thread from each batch of waiting threads, `false` otherwise.]]
 
-[[Throws:] [__thread_resource_error__ if an error occurs. __thread_interrupted__ if the wait was interrupted by a call to
-__interrupt__ on the __thread__ object associated with the current thread of execution.]]
+[[Throws:] [
+
+- __thread_resource_error__ if an error occurs.
+
+- __thread_interrupted__ if the wait was interrupted by a call to
+__interrupt__ on the __thread__ object associated with the current thread of execution.
+
+]]
 
 [[Notes:] [`wait()` is an ['interruption point].]]
 
 ]
 
 [endsect]
+[section Member Function `count_down_and_wait()`]
+
+ void count_down_and_wait();
+
+[variablelist
+
+[[Effects:] [Block until `count` threads have called `wait` or `count_down_and_wait` on `*this`. When the `count`-th thread calls `wait`, the barrier is reset and all waiting threads are unblocked.
+The reset depends on whether the barrier was constructed with a completion function or not. If there is no completion function or if the completion function result is void, the reset consists in restoring the original count. Otherwise the rest consist in assigning the result of the completion function (which must not be 0).]]
+
+[[Throws:] [
+
+- __thread_resource_error__ if an error occurs.
 
+- __thread_interrupted__ if the wait was interrupted by a call to
+__interrupt__ on the __thread__ object associated with the current thread of execution.
+
+]]
+
+[[Notes:] [`count_down_and_wait()` is an ['interruption point].]]
+
+]
+
+
+[endsect]
+[endsect]
 [endsect]

Modified: branches/release/libs/thread/doc/changes.qbk
==============================================================================
--- branches/release/libs/thread/doc/changes.qbk Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/doc/changes.qbk 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -8,23 +8,24 @@
 
 [section:changes History]
 
-[/
+[/]
 [heading Version 4.2.0 - boost 1.55]
 
 [*New Features:]
 
-* [@http://svn.boost.org/trac/boost/ticket/8273 #8273] Synchro:Add externally locked streams.
-* [@http://svn.boost.org/trac/boost/ticket/8274 #8274] Synchro:Add concurrent queue.
-* [@http://svn.boost.org/trac/boost/ticket/8515 #8515] Async: Add shared_future::then.
+* [@http://svn.boost.org/trac/boost/ticket/8274 #8274] Synchro: Add concurrent queue
 * [@http://svn.boost.org/trac/boost/ticket/8518 #8518] Synchro: Add a latch class.
+* [@http://svn.boost.org/trac/boost/ticket/8519 #8519] Synchro: Update class barrier with a completion function.
+
 * [@http://svn.boost.org/trac/boost/ticket/8615 #8615] Async: Replace make_future/make_shared_future by make_ready_future.
-* [@http://svn.boost.org/trac/boost/ticket/8627 #8627] Async: Add future<>::unwrap.
+* [@http://svn.boost.org/trac/boost/ticket/8515 #8515] Async: Add shared_future::then.
+* [@http://svn.boost.org/trac/boost/ticket/8627 #8627] Async: Add future<>::unwrap and unwrapping constructor.
 * [@http://svn.boost.org/trac/boost/ticket/8677 #8677] Async: Add future<>::get_or.
 * [@http://svn.boost.org/trac/boost/ticket/8678 #8678] Async: Add future<>::fallback_to.
 
 [*Fixed Bugs:]
 
-]
+[/]
 
 [heading Version 4.1.0 - boost 1.54]
 
@@ -416,10 +417,7 @@
   * [@http://svn.boost.org/trac/boost/ticket/7589 #7589] Synchro: Add polymorphic lockables.
 
 # Add some features based on C++ proposals, in particular
- * [@http://svn.boost.org/trac/boost/ticket/8273 #8273] Add externally locked streams
- * [@http://svn.boost.org/trac/boost/ticket/8274 #8274] Add concurrent queue
- * [@http://svn.boost.org/trac/boost/ticket/8518 #8518] Sync: Add a latch class
- * [@http://svn.boost.org/trac/boost/ticket/8519 #8519] Sync: Add a completion_latch class
+ * [@http://svn.boost.org/trac/boost/ticket/8273 #8273] Synchro: Add externally locked streams.
   * [@http://svn.boost.org/trac/boost/ticket/8513 #8513] Async: Add a basic thread_pool executor.
   * [@http://svn.boost.org/trac/boost/ticket/8514 #8514] Async: Add a thread_pool executor with work stealing.
 
@@ -428,14 +426,10 @@
   * [@http://svn.boost.org/trac/boost/ticket/7446 #7446] Async: Add when_any.
   * [@http://svn.boost.org/trac/boost/ticket/7447 #7447] Async: Add when_all.
   * [@http://svn.boost.org/trac/boost/ticket/7448 #7448] Async: Add async taking a scheduler parameter.
- * [@http://svn.boost.org/trac/boost/ticket/8515 #8515] Async: Add shared_future::then.
   * [@http://svn.boost.org/trac/boost/ticket/8516 #8516] Async: Add future/shared_future::then taking a scheduler as parameter.
- * [@http://svn.boost.org/trac/boost/ticket/8627 #8627] Async: Add future<>::unwrap.
 
 # And some additional extensions related to futures as:
 
- * [@http://svn.boost.org/trac/boost/ticket/8677 #8677] Async: Add future<>::get_or.
- * [@http://svn.boost.org/trac/boost/ticket/8678 #8678] Async: Add future<>::fallback_to.
   * [@http://svn.boost.org/trac/boost/ticket/8517 #8517] Async: Add a variadic shared_future::then.
 
 

Modified: branches/release/libs/thread/doc/future_ref.qbk
==============================================================================
--- branches/release/libs/thread/doc/future_ref.qbk Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/doc/future_ref.qbk 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -6,6 +6,7 @@
 ]
 
 
+[///////////////////////////////////]
 [section:reference Futures Reference]
 
   //#include <boost/thread/futures.hpp>
@@ -94,18 +95,27 @@
     void wait_for_all(F1& f1,Fs&... fs); // EXTENSION
 
     template<typename Iterator>
- Iterator wait_for_any(Iterator begin,Iterator end);
+ Iterator wait_for_any(Iterator begin,Iterator end); // EXTENSION
     template<typename F1,typename... Fs>
- unsigned wait_for_any(F1& f1,Fs&... fs);
+ unsigned wait_for_any(F1& f1,Fs&... fs); // EXTENSION
     
     template <typename T>
- future<typename decay<T>::type> make_future(T&& value); // EXTENSION
- future<void> make_future(); // EXTENSION
+ future<typename decay<T>::type> make_future(T&& value); // DEPRECATED
+ future<void> make_future(); // DEPRECATED
     
     template <typename T>
- shared_future<typename decay<T>::type> make_shared_future(T&& value); // EXTENSION
- shared_future<void> make_shared_future(); // EXTENSION
+ future<typename decay<T>::type> make_ready_future(T&& value); // EXTENSION
+ future<void> make_ready_future(); // EXTENSION
+ template <typename T>
+ future<T> make_ready_future(exception_ptr ex); // EXTENSION
+ template <typename T, typename E>
+ future<T> make_ready_future(E ex); // EXTENSION
+
+ template <typename T>
+ shared_future<typename decay<T>::type> make_shared_future(T&& value); // DEPRECATED
+ shared_future<void> make_shared_future(); // DEPRECATED
     
+[////////////////////////////////////////]
 [section:future_state Enumeration `state`]
 
     namespace future_state
@@ -115,8 +125,7 @@
 
 
 [endsect]
-
-
+[/////////////////////////////////////////////]
 [section:future_errc Enumeration `future_errc`]
 
   enum class future_errc
@@ -131,6 +140,7 @@
  The enum values of future_errc are distinct and not zero.
  
 [endsect]
+[///////////////////////////////////]
 [section:launch Enumeration `launch`]
 
     enum class launch
@@ -143,6 +153,7 @@
 The enum type launch is a bitmask type with launch::async and launch::deferred denoting individual bits.
 
 [endsect]
+[///////////////////////////////////////////////////////////////////////////]
 [section:is_error_code_enum Specialization `is_error_code_enum<future_errc>`]
 
   namespace system
@@ -153,6 +164,7 @@
   }
 
 [endsect]
+[///////////////////////////////////////////////////////////////]
 [section:make_error_code Non-member function `make_error_code()`]
 
   namespace system
@@ -167,6 +179,7 @@
 ]
 
 [endsect]
+[/////////////////////////////////////////////////////////////////////////]
 [section:make_error_condition Non-member function `make_error_condition()`]
 
   namespace system
@@ -181,6 +194,7 @@
 ]
 
 [endsect]
+[///////////////////////////////////////////////////////////////]
 [section:future_category Non-member function `future_category()`]
 
   const system::error_category& future_category();
@@ -195,6 +209,7 @@
 ]
 
 [endsect]
+[/////////////////////////////////////////]
 [section:future_error Class `future_error`]
 
   class future_error
@@ -206,6 +221,7 @@
       const system::error_code& code() const no_except;
   };
 
+[///////////////////////////////]
 [section:constructor Constructor]
 
       future_error(system::error_code ec);
@@ -221,6 +237,7 @@
 ]
 
 [endsect]
+[/////////////////////////////////////]
 [section:code Member function `code()`]
 
       const system::error_code& code() const no_except;
@@ -235,7 +252,7 @@
 
 
 [endsect]
-
+[/////////////////////////////////////////////////]
 [section:future_status Enumeration `future_status`]
 
   enum class future_status {
@@ -243,7 +260,7 @@
   };
 
 [endsect]
-
+[////////////////////////////////////////////////////]
 [section:unique_future __unique_future class template]
 
     template <typename R>
@@ -251,16 +268,21 @@
     {
 
     public:
- __unique_future__(__unique_future__ & rhs);// = delete;
- __unique_future__& operator=(__unique_future__& rhs);// = delete;
+ typedef R value_type; // EXTENSION
+ __unique_future__(__unique_future__ const& rhs) = delete;
+ __unique_future__& operator=(__unique_future__ const& rhs) = delete;
 
       __unique_future__() noexcept;
       ~__unique_future__();
 
       // move support
       __unique_future__(__unique_future__ && other) noexcept;
+ __unique_future__(__unique_future__<__unique_future__<R>>&& rhs); // EXTENSION
       __unique_future__& operator=(__unique_future__ && other) noexcept;
+
+ // factories
       shared_future<R> share();
+
       template<typename F>
       __unique_future__<typename boost::result_of<F(__unique_future__&)>::type>
       then(F&& func); // EXTENSION
@@ -270,11 +292,15 @@
       template<typename F>
       __unique_future__<typename boost::result_of<F(__unique_future__&)>::type>
       then(launch policy, F&& func); // EXTENSION
-
- void swap(__unique_future__& other) noexcept; // EXTENSION
+
+ see below unwrap(); // EXTENSION
+ __unique_future__ fallback_to(); // EXTENSION
+
+ void swap(__unique_future__& other) noexcept;
 
       // retrieving the value
- R&& get();
+ see below get();
+ see below get_or(see below); // EXTENSION
 
       // functions to check state
       bool valid() const noexcept;
@@ -289,7 +315,7 @@
       template <class Clock, class Duration>
       future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
 
- #if defined BOOST_THREAD_USES_DATE_TIME || defined BOOST_THREAD_DONT_USE_CHRONO
+ #if defined BOOST_THREAD_USES_DATE_TIME
       template<typename Duration>
       bool timed_wait(Duration const& rel_time) const; // DEPRECATED SINCE V3.0.0
       bool timed_wait_until(boost::system_time const& abs_time) const; // DEPRECATED SINCE V3.0.0
@@ -298,6 +324,7 @@
       state get_state() const; // EXTENSION
     };
 
+[///////////////////////////////////////////////]
 [section:default_constructor Default Constructor]
 
     __unique_future__();
@@ -315,6 +342,7 @@
 
 [endsect]
 
+[/////////////////////////////]
 [section:destructor Destructor]
 
     ~__unique_future__();
@@ -328,18 +356,18 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////]
 [section:move_constructor Move Constructor]
 
     __unique_future__(__unique_future__ && other);
 
 [variablelist
 
-[[Effects:] [Constructs a new __unique_future__, and transfers ownership of the asynchronous result associated with `other` to `*this`.]]
+[[Effects:] [Constructs a new __unique_future__, and transfers ownership of the shared state associated with `other` to `*this`.]]
 
 [[Postconditions:] [[unique_future_get_state_link `this->get_state()`] returns the value of `other->get_state()` prior to the
-call. `other->get_state()` returns __uninitialized__. If `other` was associated with an asynchronous result, that result is now
-associated with `*this`. `other` is not associated with any asynchronous result.]]
+call. `other->get_state()` returns __uninitialized__. If `other` was associated with a shared state, that result is now
+associated with `*this`. `other` is not associated with any shared state.]]
 
 [[Throws:] [Nothing.]]
 
@@ -348,18 +376,42 @@
 ]
 
 [endsect]
+[///////////////////////////////////////////////////////////////////]
+[section:unwrap_move_constructor Unwrap Move Constructor - EXTENSION]
+
+ __unique_future__(__unique_future__<__unique_future__<R>>&& other); // EXTENSION
+
+[warning This constructor is experimental and subject to change in future versions.
+There are not too much tests yet, so it is possible that you can find out some trivial bugs :(]
 
+[variablelist
+
+[[Requires:] [`other.valid()`.]
+[[Effects:] [Constructs a new __unique_future__, and transfers ownership of the shared state associated with `other` and unwrapping the inner future (see `unwrap()`).]]
+
+[[Postconditions:] [[unique_future_get_state_link `this->get_state()`] returns the value of `other->get_state()` prior to the
+call. `other->get_state()` returns __uninitialized__. The associated shared state is now
+unwrapped and the inner future shared state is associated with `*this`. `other` is not associated with any shared state, `! other.valid()`.]]
+
+[[Throws:] [Nothing.]]
+
+[[Notes:] [If the compiler does not support rvalue-references, this is implemented using the boost.thread move emulation.]]
+
+]
+
+[endsect]
+[////////////////////////////////////////////////]
 [section:move_assignment Move Assignment Operator]
 
     __unique_future__& operator=(__unique_future__ && other);
 
 [variablelist
 
-[[Effects:] [Transfers ownership of the asynchronous result associated with `other` to `*this`.]]
+[[Effects:] [Transfers ownership of the shared state associated with `other` to `*this`.]]
 
 [[Postconditions:] [[unique_future_get_state_link `this->get_state()`] returns the value of `other->get_state()` prior to the
-call. `other->get_state()` returns __uninitialized__. If `other` was associated with an asynchronous result, that result is now
-associated with `*this`. `other` is not associated with any asynchronous result. If `*this` was associated with an asynchronous
+call. `other->get_state()` returns __uninitialized__. If `other` was associated with a shared state, that result is now
+associated with `*this`. `other` is not associated with any shared state. If `*this` was associated with an asynchronous
 result prior to the call, that result no longer has an associated __unique_future__ instance.]]
 
 [[Throws:] [Nothing.]]
@@ -369,51 +421,57 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////]
 [section:swap Member function `swap()`]
 
     void swap(__unique_future__ & other) no_except;
 
 [variablelist
 
-[[Effects:] [Swaps ownership of the asynchronous results associated with `other` and `*this`.]]
+[[Effects:] [Swaps ownership of the shared states associated with `other` and `*this`.]]
 
 [[Postconditions:] [[unique_future_get_state_link `this->get_state()`] returns the value of `other->get_state()` prior to the
-call. `other->get_state()` returns the value of `this->get_state()` prior to the call. If `other` was associated with an
-asynchronous result, that result is now associated with `*this`, otherwise `*this` has no associated result. If `*this` was
-associated with an asynchronous result, that result is now associated with `other`, otherwise `other` has no associated result.]]
+call. `other->get_state()` returns the value of `this->get_state()` prior to the call. If `other` was associated with a
+shared state, that result is now associated with `*this`, otherwise `*this` has no associated result. If `*this` was
+associated with a shared state, that result is now associated with `other`, otherwise `other` has no associated result.]]
 
 [[Throws:] [Nothing.]]
 
 ]
 
 [endsect]
-
-
+[///////////////////////////////////]
 [section:get Member function `get()`]
 
- R&& get();
+ R get();
     R& __unique_future__<R&>::get();
     void __unique_future__<void>::get();
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready as-if by a call to
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready as-if by a call to
 __unique_future_wait__, and retrieves the result (whether that is a value or an exception).]]
 
-[[Returns:] [If the result type `R` is a reference, returns the stored reference. If `R` is `void`, there is no return
-value. Otherwise, returns an rvalue-reference to the value stored in the asynchronous result.]]
+[[Returns:] [
+
+- `__unique_future__<R&>::get()` return the stored reference.
+
+- `__unique_future__<void>::get()`, there is no return value.
+
+- `__unique_future__<R>::get()` returns an rvalue-reference to the value stored in the shared state.
+
+]]
 
 [[Postconditions:] [[unique_future_is_ready_link `this->is_ready()`] returns `true`. [unique_future_get_state_link
 `this->get_state()`] returns __ready__.]]
 
 [[Throws:] [
 
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
 
-- Any exception stored in the asynchronous result in place of a value.
+- Any exception stored in the shared state in place of a value.
 ]]
 
 [[Notes:] [`get()` is an ['interruption point].]]
@@ -421,19 +479,59 @@
 ]
 
 [endsect]
+[/////////////////////////////////////////////////////]
+[section:get_or Member function `get_or()` - EXTENSION]
+
+ R get_or(R&& v); // EXTENSION
+ R get_or(R const& v); // EXTENSION
+ R& __unique_future__<R&>::get_or(R& v); // EXTENSION
+ void __unique_future__<void>::get_or(); // EXTENSION
+
+[warning These functions are experimental and subject to change in future versions.
+There are not too much tests yet, so it is possible that you can find out some trivial bugs :(]
+
+[variablelist
+
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready as-if by a call to
+__unique_future_wait__, and depending on whether the shared state `has_value()` the retrieves the result.]]
+
+[[Returns:] [
+
+- `__unique_future__<R&>::get_or(v)` return the stored reference if has_value() and the passes parameter otherwise.
+
+- `__unique_future__<void>::get_or()`, there is no return value, but the function doesn't throws even if the shared state contained an exception.
+
+- `__unique_future__<R>::get_or(v)` returns an rvalue-reference to the value stored in the shared state if `has_value()` and an rvalue-reference build with the parameter `v`.
+
+]]
+
+[[Postconditions:] [[unique_future_is_ready_link `this->is_ready()`] returns `true`. [unique_future_get_state_link
+`this->get_state()`] returns __ready__.]]
+
+[[Throws:] [
+
+- __future_uninitialized__ if `*this` is not associated with a shared state.
+
+]]
+
+[[Notes:] [`get_or()` is an ['interruption point].]]
+
+]
 
+[endsect]
+[/////////////////////////////////////]
 [section:wait Member function `wait()`]
 
     void wait() const;
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready. If the result is not ready on
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready. If the result is not ready on
 entry, and the result has a ['wait callback] set, that callback is invoked prior to waiting.]]
 
 [[Throws:] [
 
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result
 associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
@@ -448,7 +546,7 @@
 ]
 
 [endsect]
-
+[//////////////////////////////////////////////////////////////////////////////////]
 [section:timed_wait_duration Member function `timed_wait()` DEPRECATED SINCE V3.0.0]
 
     template<typename Duration>
@@ -464,16 +562,16 @@
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready, or the time specified by
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready, or the time specified by
 `wait_duration` has elapsed. If the result is not ready on entry, and the result has a ['wait callback] set, that callback is
 invoked prior to waiting.]]
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result, and that result is ready before the specified time has
+[[Returns:] [`true` if `*this` is associated with a shared state, and that result is ready before the specified time has
 elapsed, `false` otherwise.]]
 
 [[Throws:] [
 
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
 
@@ -487,7 +585,7 @@
 ]
 
 [endsect]
-
+[//////////////////////////////////////////////////////////////////////////////////]
 [section:timed_wait_absolute Member function `timed_wait()` DEPRECATED SINCE V3.0.0]
 
     bool timed_wait(boost::system_time const& wait_timeout);
@@ -502,16 +600,16 @@
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready, or the time point specified by
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready, or the time point specified by
 `wait_timeout` has passed. If the result is not ready on entry, and the result has a ['wait callback] set, that callback is invoked
 prior to waiting.]]
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result, and that result is ready before the specified time has
+[[Returns:] [`true` if `*this` is associated with a shared state, and that result is ready before the specified time has
 passed, `false` otherwise.]]
 
 [[Throws:] [
 
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
 
@@ -525,7 +623,7 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////]
 [section:wait_for Member function `wait_for()`]
 
       template <class Rep, class Period>
@@ -533,7 +631,7 @@
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready, or the time specified by
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready, or the time specified by
 `wait_duration` has elapsed. If the result is not ready on entry, and the result has a ['wait callback] set, that callback is
 invoked prior to waiting.]]
 
@@ -549,7 +647,7 @@
 
 [[Throws:] [
 
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
 
@@ -563,7 +661,7 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////////]
 [section:wait_until Member function `wait_until()`]
 
       template <class Clock, class Duration>
@@ -571,7 +669,7 @@
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready, or the time point specified by
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready, or the time point specified by
 `wait_timeout` has passed. If the result is not ready on entry, and the result has a ['wait callback] set, that callback is invoked
 prior to waiting.]]
 
@@ -587,7 +685,7 @@
 
 [[Throws:] [
 
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
 
@@ -601,15 +699,14 @@
 ]
 
 [endsect]
-
-
+[///////////////////////////////////////]
 [section:valid Member function `valid()`]
 
     bool valid() const noexcept;
 
 [variablelist
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result, `false`
+[[Returns:] [`true` if `*this` is associated with a shared state, `false`
 otherwise.]]
 
 [[Throws:] [Nothing.]]
@@ -617,13 +714,14 @@
 ]
 
 [endsect]
+[///////////////////////////////////////////////////////]
 [section:is_ready Member function `is_ready()` EXTENSION]
 
     bool is_ready() const;
 
 [variablelist
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result and that result is ready for retrieval, `false`
+[[Returns:] [`true` if `*this` is associated with a shared state and that result is ready for retrieval, `false`
 otherwise.]]
 
 [[Throws:] [Nothing.]]
@@ -631,14 +729,14 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////////////////]
 [section:has_value Member function `has_value()` EXTENSION]
 
     bool has_value() const;
 
 [variablelist
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result, that result is ready for retrieval, and the result is a
+[[Returns:] [`true` if `*this` is associated with a shared state, that result is ready for retrieval, and the result is a
 stored value, `false` otherwise.]]
 
 [[Throws:] [Nothing.]]
@@ -646,14 +744,14 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////////////////////////]
 [section:has_exception Member function `has_exception()` EXTENSION]
 
     bool has_exception() const;
 
 [variablelist
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result, that result is ready for retrieval, and the result is a
+[[Returns:] [`true` if `*this` is associated with a shared state, that result is ready for retrieval, and the result is a
 stored exception, `false` otherwise.]]
 
 [[Throws:] [Nothing.]]
@@ -661,25 +759,41 @@
 ]
 
 [endsect]
-
-[section:get_state Member function `get_state()`]
+[/////////////////////////////////////////////////////////]
+[section:get_state Member function `get_state()` EXTENSION]
 
     future_state::state get_state();
 
 [variablelist
 
-[[Effects:] [Determine the state of the asynchronous result associated with `*this`, if any.]]
+[[Effects:] [Determine the state of the shared state associated with `*this`, if any.]]
 
-[[Returns:] [__uninitialized__ if `*this` is not associated with an asynchronous result. __ready__ if the asynchronous result
+[[Returns:] [__uninitialized__ if `*this` is not associated with a shared state. __ready__ if the shared state
 associated with `*this` is ready for retrieval, __waiting__ otherwise.]]
 
 [[Throws:] [Nothing.]]
 
 ]
 
+
 [endsect]
+[///////////////////////////////////////]
+[section:share Member function `share()`]
+
+ shared_future<R> share();
+
+[variablelist
 
-[section:then Member function `then()`]
+[[Returns:] [`shared_future<R>(boost::move(*this))`.]]
+
+[[Postconditions:] [`this->valid() == false`.]]
+
+]
+
+
+[endsect]
+[/////////////////////////////////////////////////]
+[section:then Member function `then()` - EXTENSION]
 
       template<typename F>
       __unique_future__<typename boost::result_of<F(__unique_future__&)>::type>
@@ -691,13 +805,10 @@
       __unique_future__<typename boost::result_of<F(__unique_future__&)>::type>
       then(launch policy, F&& func); // EXTENSION
 
-
 [warning These functions are experimental and subject to change in future versions.
 There are not too much tests yet, so it is possible that you can find out some trivial bugs :(]
 
-[note These functions are based on the [@http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3558.pdf [*N3558 - A Standardized Representation of Asynchronous Operations]] C++1y proposal by N. Gustafsson, A. Laksberg, H. Sutter, S. Mithani.]
-
-
+[note These functions are based on the [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3634.pdf [*N3634 - Improvements to std::future<T> and related APIs]] C++1y proposal by N. Gustafsson, A. Laksberg, H. Sutter, S. Mithani.]
 
 [variablelist
 
@@ -715,35 +826,67 @@
 - When the scheduler or launch policy is not provided the continuation inherits the
 parent's launch policy or scheduler.
 
-- If the parent was created with std::promise or with a packaged_task (has no associated launch policy), the
-continuation behaves the same as the third overload with a policy argument of launch::async | launch::deferred and
+- If the parent was created with `promise<<` or with a `packaged_task<>` (has no associated launch policy), the
+continuation behaves the same as the third overload with a policy argument of `launch::async | launch::deferred` and
 the same argument for func.
 
-- If the parent has a policy of launch::deferred and the continuation does not have a specified launch policy or
-scheduler, then the parent is filled by immediately calling .wait(), and the policy of the antecedent is
-launch::deferred
+- If the parent has a policy of `launch::deferred` and the continuation does not have a specified launch policy or
+scheduler, then the parent is filled by immediately calling `.wait()`, and the policy of the antecedent is
+`launch::deferred`.
 
 ]]
 
-[[Returns:] [An object of type future<typename boost::result_of<F(__unique_future__&)> that refers to the shared state created by the continuation.]]
+[[Returns:] [An object of type `__unique_future__<typename boost::result_of<F(__unique_future__)>` that refers to the shared state created by the continuation.]]
 
 [[Postconditions:] [
 
-- The future object is moved to the parameter of the continuation function .
+- The `__unique_future__` object passed to the parameter of the continuation function is a copy of the original `__unique_future__`.
 
-- valid() == false on original future object immediately after it returns.
+- `valid() == false` on original future object immediately after it returns.
 
 ]]
 
 ]
 
 [endsect]
+[///////////////////////////////////////////////////]
+[section:unwrap Member function `unwrap()` EXTENSION]
 
+ template <typename R2>
+ __unique_future__<R2> __unique_future__<__unique_future__<R2>>::unwrap(); // EXTENSION
+ template <typename R2>
+ __shared_future__<R2> __unique_future__<__shared_future__<R2>>::unwrap(); // EXTENSION
+
+[warning These functions are experimental and subject to change in future versions.
+There are not too much tests yet, so it is possible that you can find out some trivial bugs :(]
+
+[note These functions are based on the [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3634.pdf [*N3634 - Improvements to std::future<T> and related APIs]] C++1y proposal by N. Gustafsson, A. Laksberg, H. Sutter, S. Mithani.]
+
+[variablelist
+
+[[Notes:] [Removes the outermost future and returns a future with the associated state been a proxy of inner future.]]
+
+[[Effects:] [
+
+- Returns a future that becomes ready when the shared state of the inner future is ready.
+
+]]
+
+[[Returns:] [An object of type future with the associated state been a proxy of inner future.]]
+
+[[Postconditions:] [
+
+- The returned future has `valid() == true` regardless of the validity of the inner future.
+
+]]
+
+]
 
-
 
 [endsect]
 
+[endsect]
+[////////////////////////////////////////////////////]
 [section:shared_future `shared_future` class template]
 
     template <typename R>
@@ -751,6 +894,7 @@
     {
     public:
       typedef future_state::state state; // EXTENSION
+ typedef R value_type; // EXTENSION
 
       shared_future() noexcept;
       ~shared_future();
@@ -765,10 +909,21 @@
       shared_future& operator=(shared_future && other) noexcept;
       shared_future& operator=(__unique_future__<R> && other) noexcept;
 
+ // factories
+ template<typename F>
+ __unique_future__<typename boost::result_of<F(shared_future&)>::type>
+ then(F&& func); // EXTENSION
+ template<typename S, typename F>
+ __unique_future__<typename boost::result_of<F(shared_future&)>::type>
+ then(S& scheduler, F&& func); // EXTENSION NOT_YET_IMPLEMENTED
+ template<typename F>
+ __unique_future__<typename boost::result_of<F(shared_future&)>::type>
+ then(launch policy, F&& func); // EXTENSION
+
       void swap(shared_future& other);
 
       // retrieving the value
- R get();
+ see below get();
 
       // functions to check state, and wait for ready
       bool valid() const noexcept;
@@ -789,8 +944,10 @@
       bool timed_wait_until(boost::system_time const& abs_time) const; // DEPRECATED SINCE V3.0.0
     #endif
       state get_state() const noexcept; // EXTENSION
+
     };
 
+[///////////////////////////////////////////////]
 [section:default_constructor Default Constructor]
 
     shared_future();
@@ -807,22 +964,31 @@
 ]
 
 [endsect]
-
+[///////////////////////////////////]
 [section:get Member function `get()`]
 
     const R& get();
+ R& get();
+ void get();
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready as-if by a call to
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready as-if by a call to
 __shared_future_wait__, and returns a `const` reference to the result.]]
 
-[[Returns:] [If the result type `R` is a reference, returns the stored reference. If `R` is `void`, there is no return
-value. Otherwise, returns a `const` reference to the value stored in the asynchronous result.]]
+[[Returns:] [
+
+- `shared_future<R&>::get()` return the stored reference.
+
+- `shared_future<void>::get()`, there is no return value.
+
+- `shared_future<R>::get()` returns a `const` reference to the value stored in the shared state.
+
+]]
 
 [[Throws:] [
 
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
 ]]
@@ -832,18 +998,18 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////]
 [section:wait Member function `wait()`]
 
     void wait() const;
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready. If the result is not ready on
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready. If the result is not ready on
 entry, and the result has a ['wait callback] set, that callback is invoked prior to waiting.]]
 
 [[Throws:] [
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
 
@@ -858,7 +1024,7 @@
 ]
 
 [endsect]
-
+[//////////////////////////////////////////////////////////]
 [section:timed_wait_duration Member function `timed_wait()`]
 
     template<typename Duration>
@@ -866,16 +1032,16 @@
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready, or the time specified by
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready, or the time specified by
 `wait_duration` has elapsed. If the result is not ready on entry, and the result has a ['wait callback] set, that callback is
 invoked prior to waiting.]]
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result, and that result is ready before the specified time has
+[[Returns:] [`true` if `*this` is associated with a shared state, and that result is ready before the specified time has
 elapsed, `false` otherwise.]]
 
 [[Throws:] [
 
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
 
@@ -889,22 +1055,22 @@
 ]
 
 [endsect]
-
+[//////////////////////////////////////////////////////////]
 [section:timed_wait_absolute Member function `timed_wait()`]
 
     bool timed_wait(boost::system_time const& wait_timeout);
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready, or the time point specified by
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready, or the time point specified by
 `wait_timeout` has passed. If the result is not ready on entry, and the result has a ['wait callback] set, that callback is invoked
 prior to waiting.]]
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result, and that result is ready before the specified time has
+[[Returns:] [`true` if `*this` is associated with a shared state, and that result is ready before the specified time has
 passed, `false` otherwise.]]
 
 [[Throws:] [
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
 
@@ -918,7 +1084,7 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////]
 [section:wait_for Member function `wait_for()`]
 
       template <class Rep, class Period>
@@ -927,7 +1093,7 @@
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready, or the time specified by
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready, or the time specified by
 `wait_duration` has elapsed. If the result is not ready on entry, and the result has a ['wait callback] set, that callback is
 invoked prior to waiting.]]
 
@@ -942,7 +1108,7 @@
 ]]
 
 [[Throws:] [
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
 
@@ -956,7 +1122,7 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////////]
 [section:wait_until Member function `wait_until()`]
 
       template <class Clock, class Duration>
@@ -964,7 +1130,7 @@
 
 [variablelist
 
-[[Effects:] [If `*this` is associated with an asynchronous result, waits until the result is ready, or the time point specified by
+[[Effects:] [If `*this` is associated with a shared state, waits until the result is ready, or the time point specified by
 `wait_timeout` has passed. If the result is not ready on entry, and the result has a ['wait callback] set, that callback is invoked
 prior to waiting.]]
 
@@ -979,7 +1145,7 @@
 ]]
 
 [[Throws:] [
-- __future_uninitialized__ if `*this` is not associated with an asynchronous result.
+- __future_uninitialized__ if `*this` is not associated with a shared state.
 
 - __thread_interrupted__ if the result associated with `*this` is not ready at the point of the call, and the current thread is interrupted.
 
@@ -994,14 +1160,14 @@
 ]
 
 [endsect]
-
+[///////////////////////////////////////]
 [section:valid Member function `valid()`]
 
     bool valid() const noexcept;
 
 [variablelist
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result, `false`
+[[Returns:] [`true` if `*this` is associated with a shared state, `false`
 otherwise.]]
 
 [[Throws:] [Nothing.]]
@@ -1009,14 +1175,14 @@
 ]
 
 [endsect]
-
+[///////////////////////////////////////////////////////]
 [section:is_ready Member function `is_ready()` EXTENSION]
 
     bool is_ready() const;
 
 [variablelist
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result, and that result is ready for retrieval, `false`
+[[Returns:] [`true` if `*this` is associated with a shared state, and that result is ready for retrieval, `false`
 otherwise.]]
 
 [[Throws:] [Nothing.]]
@@ -1024,14 +1190,14 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////////////////]
 [section:has_value Member function `has_value()` EXTENSION]
 
     bool has_value() const;
 
 [variablelist
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result, that result is ready for retrieval, and the result is a
+[[Returns:] [`true` if `*this` is associated with a shared state, that result is ready for retrieval, and the result is a
 stored value, `false` otherwise.]]
 
 [[Throws:] [Nothing.]]
@@ -1039,14 +1205,14 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////////////////////////]
 [section:has_exception Member function `has_exception()` EXTENSION]
 
     bool has_exception() const;
 
 [variablelist
 
-[[Returns:] [`true` if `*this` is associated with an asynchronous result, that result is ready for retrieval, and the result is a
+[[Returns:] [`true` if `*this` is associated with a shared state, that result is ready for retrieval, and the result is a
 stored exception, `false` otherwise.]]
 
 [[Throws:] [Nothing.]]
@@ -1054,16 +1220,16 @@
 ]
 
 [endsect]
-
-[section:get_state Member function `get_state()`]
+[/////////////////////////////////////////////////////////]
+[section:get_state Member function `get_state()` EXTENSION]
 
     future_state::state get_state();
 
 [variablelist
 
-[[Effects:] [Determine the state of the asynchronous result associated with `*this`, if any.]]
+[[Effects:] [Determine the state of the shared state associated with `*this`, if any.]]
 
-[[Returns:] [__uninitialized__ if `*this` is not associated with an asynchronous result. __ready__ if the asynchronous result
+[[Returns:] [__uninitialized__ if `*this` is not associated with a shared state. __ready__ if the shared state
 associated with `*this` is ready for retrieval, __waiting__ otherwise.]]
 
 [[Throws:] [Nothing.]]
@@ -1071,22 +1237,81 @@
 ]
 
 [endsect]
+[///////////////////////////////////////////////]
+[section:then Member function `then()` EXTENSION]
 
+ template<typename F>
+ __unique_future__<typename boost::result_of<F(shared_future&)>::type>
+ then(F&& func); // EXTENSION
+ template<typename S, typename F>
+ __unique_future__<typename boost::result_of<F(shared_future&)>::type>
+ then(S& scheduler, F&& func); // EXTENSION NOT_YET_IMPLEMENTED
+ template<typename F>
+ __unique_future__<typename boost::result_of<F(shared_future&)>::type>
+ then(launch policy, F&& func); // EXTENSION
+
+
+[warning These functions are experimental and subject to change in future versions.
+There are not too much tests yet, so it is possible that you can find out some trivial bugs :(]
+
+[note These functions are based on the [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3634.pdf [*N3634 - Improvements to std::future<T> and related APIs]] C++1y proposal by N. Gustafsson, A. Laksberg, H. Sutter, S. Mithani.]
+
+[variablelist
+
+[[Notes:] [The three functions differ only by input parameters. The first only takes a callable object which accepts a
+shared_future object as a parameter. The second function takes a scheduler as the first parameter and a callable object as
+the second parameter. The third function takes a launch policy as the first parameter and a callable object as the
+second parameter.]]
+
+[[Effects:] [
+
+- The continuation is called when the object's shared state is ready (has a value or exception stored).
+
+- The continuation launches according to the specified policy or scheduler.
+
+- When the scheduler or launch policy is not provided the continuation inherits the
+parent's launch policy or scheduler.
+
+- If the parent was created with `promise` or with a `packaged_task` (has no associated launch policy), the
+continuation behaves the same as the third overload with a policy argument of `launch::async | launch::deferred` and
+the same argument for func.
+
+- If the parent has a policy of `launch::deferred` and the continuation does not have a specified launch policy or
+scheduler, then the parent is filled by immediately calling `.wait()`, and the policy of the antecedent is
+`launch::deferred`
+
+]]
+
+[[Returns:] [An object of type `__unique_future__<typename boost::result_of<F(shared_future)>` that refers to the shared state created by the continuation.]]
+
+[[Postconditions:] [
+
+- The future object is moved to the parameter of the continuation function .
+
+- `valid() == false` on original future object immediately after it returns.
+
+]]
+
+]
 
 [endsect]
 
+[endsect]
+
+[////////////////////////////////////////]
 [section:promise `promise` class template]
 
     template <typename R>
     class promise
     {
     public:
-
+ typedef R value_type; // EXTENSION
+
       promise();
       template <class Allocator>
       promise(allocator_arg_t, Allocator a);
- promise & operator=(const promise & rhs);// = delete;
- promise(const promise & rhs);// = delete;
+ promise & operator=(promise const& rhs) = delete;
+ promise(promise const& rhs) = delete;
       ~promise();
 
       // Move support
@@ -1100,15 +1325,20 @@
       // Set the value
       void set_value(see below);
       void set_exception(boost::exception_ptr e);
+ template <typename E>
+ void set_exception(E e); // EXTENSION
 
       // setting the result with deferred notification
       void set_value_at_thread_exit(see below);
       void set_exception_at_thread_exit(exception_ptr p);
+ template <typename E>
+ void set_exception_at_thread_exit(E p); // EXTENSION
 
       template<typename F>
       void set_wait_callback(F f); // EXTENSION
     };
 
+[///////////////////////////////////////////////]
 [section:default_constructor Default Constructor]
 
     promise();
@@ -1122,7 +1352,7 @@
 ]
 
 [endsect]
-
+[///////////////////////////////////////////////]
 [section:alloc_constructor Allocator Constructor]
 
       template <class Allocator>
@@ -1139,9 +1369,7 @@
 ]
 
 [endsect]
-
-
-
+[/////////////////////////////////////////]
 [section:move_constructor Move Constructor]
 
     promise(promise && other);
@@ -1158,7 +1386,7 @@
 ]
 
 [endsect]
-
+[////////////////////////////////////////////////]
 [section:move_assignment Move Assignment Operator]
 
     promise& operator=(promise && other);
@@ -1176,7 +1404,7 @@
 ]
 
 [endsect]
-
+[/////////////////////////////]
 [section:destructor Destructor]
 
     ~promise();
@@ -1191,14 +1419,14 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////////]
 [section:get_future Member Function `get_future()`]
 
     __unique_future__<R> get_future();
 
 [variablelist
 
-[[Effects:] [If `*this` was not associated with a result, allocate storage for a new asynchronous result and associate it with
+[[Effects:] [If `*this` was not associated with a result, allocate storage for a new shared state and associate it with
 `*this`. Returns a __unique_future__ associated with the result associated with `*this`. ]]
 
 [[Throws:] [__future_already_retrieved__ if the future associated with the task has already been retrieved. `std::bad_alloc` if any
@@ -1207,7 +1435,7 @@
 ]
 
 [endsect]
-
+[///////////////////////////////////////////////]
 [section:set_value Member Function `set_value()`]
 
     void set_value(R&& r);
@@ -1218,13 +1446,13 @@
 [variablelist
 
 [[Effects:] [
-- If BOOST_THREAD_PROVIDES_PROMISE_LAZY is defined and if `*this` was not associated with a result, allocate storage for a new asynchronous result and associate it with `*this`.
+- If BOOST_THREAD_PROVIDES_PROMISE_LAZY is defined and if `*this` was not associated with a result, allocate storage for a new shared state and associate it with `*this`.
 
-- Store the value `r` in the asynchronous result associated with `*this`. Any threads blocked waiting for the asynchronous
+- Store the value `r` in the shared state associated with `*this`. Any threads blocked waiting for the asynchronous
 result are woken.
 ]]
 
-[[Postconditions:] [All futures waiting on the asynchronous result are ['ready] and __unique_future_has_value__ or
+[[Postconditions:] [All futures waiting on the shared state are ['ready] and __unique_future_has_value__ or
 __shared_future_has_value__ for those futures shall return `true`.]]
 
 [[Throws:] [
@@ -1239,21 +1467,23 @@
 ]
 
 [endsect]
-
+[///////////////////////////////////////////////////////]
 [section:set_exception Member Function `set_exception()`]
 
     void set_exception(boost::exception_ptr e);
+ template <typename E>
+ void set_exception(E e); // EXTENSION
 
 [variablelist
 
 [[Effects:] [
-- If BOOST_THREAD_PROVIDES_PROMISE_LAZY is defined and if `*this` was not associated with a result, allocate storage for a new asynchronous result and associate it with
+- If BOOST_THREAD_PROVIDES_PROMISE_LAZY is defined and if `*this` was not associated with a result, allocate storage for a new shared state and associate it with
 `*this`.
 
-- Store the exception `e` in the asynchronous result associated with `*this`. Any threads blocked waiting for the asynchronous
+- Store the exception `e` in the shared state associated with `*this`. Any threads blocked waiting for the asynchronous
 result are woken.]]
 
-[[Postconditions:] [All futures waiting on the asynchronous result are ['ready] and __unique_future_has_exception__ or
+[[Postconditions:] [All futures waiting on the shared state are ['ready] and __unique_future_has_exception__ or
 __shared_future_has_exception__ for those futures shall return `true`.]]
 
 [[Throws:] [
@@ -1267,7 +1497,7 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////////////////////////////////////]
 [section:set_value_at_thread_exit Member Function `set_value_at_thread_exit()`]
 
     void set_value_at_thread_exit(R&& r);
@@ -1296,10 +1526,12 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////////////////////////////////////////////]
 [section:set_exception_at_thread_exit Member Function `set_exception_at_thread_exit()`]
 
     void set_exception_at_thread_exit(boost::exception_ptr e);
+ template <typename E>
+ void set_exception_at_thread_exit(E p); // EXTENSION
 
 [variablelist
 
@@ -1308,7 +1540,7 @@
 Schedules that state to be made ready when the current thread exits, after all objects of thread storage duration
  associated with the current thread have been destroyed.]]
 
-[[Postconditions:] [All futures waiting on the asynchronous result are ['ready] and __unique_future_has_exception__ or
+[[Postconditions:] [All futures waiting on the shared state are ['ready] and __unique_future_has_exception__ or
 __shared_future_has_exception__ for those futures shall return `true`.]]
 
 [[Throws:] [
@@ -1322,6 +1554,7 @@
 ]
 
 [endsect]
+[/////////////////////////////////////////////////////////////////////////]
 [section:set_wait_callback Member Function `set_wait_callback()` EXTENSION]
 
     template<typename F>
@@ -1332,7 +1565,7 @@
 [[Preconditions:] [The expression `f(t)` where `t` is a lvalue of type __promise__ shall be well-formed. Invoking a copy of
 `f` shall have the same effect as invoking `f`]]
 
-[[Effects:] [Store a copy of `f` with the asynchronous result associated with `*this` as a ['wait callback]. This will replace any
+[[Effects:] [Store a copy of `f` with the shared state associated with `*this` as a ['wait callback]. This will replace any
 existing wait callback store alongside that result. If a thread subsequently calls one of the wait functions on a __unique_future__
 or __shared_future__ associated with this result, and the result is not ['ready], `f(*this)` shall be invoked.]]
 
@@ -1343,7 +1576,7 @@
 [endsect]
 
 [endsect]
-
+[////////////////////////////////////////////////////]
 [section:packaged_task `packaged_task` class template]
 
     template<typename S>
@@ -1354,8 +1587,8 @@
     class packaged_task<R(ArgTypes)>
     {
     public:
- packaged_task(packaged_task&);// = delete;
- packaged_task& operator=(packaged_task&);// = delete;
+ packaged_task(packaged_task const&) = delete;
+ packaged_task& operator=(packaged_task const&) = delete;
 
       // construction and destruction
       packaged_task() noexcept;
@@ -1392,6 +1625,7 @@
       void set_wait_callback(F f); // EXTENSION
     };
 
+[/////////////////////////////////////////]
 [section:task_constructor Task Constructor]
 
     packaged_task(R(*f)(ArgTypes...));
@@ -1421,7 +1655,7 @@
 ]
 
 [endsect]
-
+[///////////////////////////////////////////////]
 [section:alloc_constructor Allocator Constructor]
 
       template <class Allocator>
@@ -1445,7 +1679,7 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////]
 [section:move_constructor Move Constructor]
 
     packaged_task(packaged_task && other);
@@ -1462,8 +1696,7 @@
 ]
 
 [endsect]
-
-
+[////////////////////////////////////////////////]
 [section:move_assignment Move Assignment Operator]
 
     packaged_task& operator=(packaged_task && other);
@@ -1481,7 +1714,7 @@
 ]
 
 [endsect]
-
+[/////////////////////////////]
 [section:destructor Destructor]
 
     ~packaged_task();
@@ -1496,7 +1729,7 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////////]
 [section:get_future Member Function `get_future()`]
 
     __unique_future__<R> get_future();
@@ -1511,7 +1744,7 @@
 ]
 
 [endsect]
-
+[////////////////////////////////////////////////////]
 [section:call_operator Member Function `operator()()`]
 
     void operator()();
@@ -1519,10 +1752,10 @@
 [variablelist
 
 [[Effects:] [Invoke the task associated with `*this` and store the result in the corresponding future. If the task returns normally,
-the return value is stored as the asynchronous result, otherwise the exception thrown is stored. Any threads blocked waiting for the
-asynchronous result associated with this task are woken.]]
+the return value is stored as the shared state, otherwise the exception thrown is stored. Any threads blocked waiting for the
+shared state associated with this task are woken.]]
 
-[[Postconditions:] [All futures waiting on the asynchronous result are ['ready]]]
+[[Postconditions:] [All futures waiting on the shared state are ['ready]]]
 
 [[Throws:] [
 
@@ -1533,7 +1766,7 @@
 ]
 
 [endsect]
-
+[///////////////////////////////////////////////////////////////////////////////]
 [section:make_ready_at_thread_exit Member Function `make_ready_at_thread_exit()`]
 
       void make_ready_at_thread_exit(ArgTypes...);
@@ -1541,7 +1774,7 @@
 [variablelist
 
 [[Effects:] [Invoke the task associated with `*this` and store the result in the corresponding future. If the task returns normally,
-the return value is stored as the asynchronous result, otherwise the exception thrown is stored.
+the return value is stored as the shared state, otherwise the exception thrown is stored.
 In either case, this is done without making that state ready immediately.
 Schedules the shared state to be made ready when the current thread exits, after all objects of thread storage
 duration associated with the current thread have been destroyed.]]
@@ -1556,8 +1789,7 @@
 ]
 
 [endsect]
-
-
+[///////////////////////////////////////]
 [section:reset Member Function `reset()`]
 
       void reset();
@@ -1572,7 +1804,7 @@
 ]
 
 [endsect]
-
+[/////////////////////////////////////////////////////////////////////////]
 [section:set_wait_callback Member Function `set_wait_callback()` EXTENSION]
 
     template<typename F>
@@ -1596,8 +1828,7 @@
 
 
 [endsect]
-
-
+[//////////////////////////////////////////////////////]
 [section:decay_copy Non-member function `decay_copy()`]
   template <class T>
   typename decay<T>::type decay_copy(T&& v)
@@ -1606,7 +1837,7 @@
   }
 
 [endsect]
-
+[///////////////////////////////////////////]
 [section:async Non-member function `async()`]
 
    
@@ -1764,24 +1995,23 @@
 
 
 [endsect]
-
-
-[section:wait_for_any Non-member function `wait_for_any()`]
+[/////////////////////////////////////////////////////////////////////]
+[section:wait_for_any Non-member function `wait_for_any()` - EXTENSION]
 
     template<typename Iterator>
- Iterator wait_for_any(Iterator begin,Iterator end);
+ Iterator wait_for_any(Iterator begin,Iterator end); // EXTENSION
 
     template<typename F1,typename F2>
- unsigned wait_for_any(F1& f1,F2& f2);
+ unsigned wait_for_any(F1& f1,F2& f2); // EXTENSION
 
     template<typename F1,typename F2,typename F3>
- unsigned wait_for_any(F1& f1,F2& f2,F3& f3);
+ unsigned wait_for_any(F1& f1,F2& f2,F3& f3); // EXTENSION
 
     template<typename F1,typename F2,typename F3,typename F4>
- unsigned wait_for_any(F1& f1,F2& f2,F3& f3,F4& f4);
+ unsigned wait_for_any(F1& f1,F2& f2,F3& f3,F4& f4); // EXTENSION
 
     template<typename F1,typename F2,typename F3,typename F4,typename F5>
- unsigned wait_for_any(F1& f1,F2& f2,F3& f3,F4& f4,F5& f5);
+ unsigned wait_for_any(F1& f1,F2& f2,F3& f3,F4& f4,F5& f5); // EXTENSION
 
 [variablelist
 
@@ -1805,23 +2035,23 @@
 
 
 [endsect]
-
-[section:wait_for_all Non-member function `wait_for_all()`]
+[/////////////////////////////////////////////////////////////////////]
+[section:wait_for_all Non-member function `wait_for_all()` - EXTENSION]
 
     template<typename Iterator>
- void wait_for_all(Iterator begin,Iterator end);
+ void wait_for_all(Iterator begin,Iterator end); // EXTENSION
 
     template<typename F1,typename F2>
- void wait_for_all(F1& f1,F2& f2);
+ void wait_for_all(F1& f1,F2& f2); // EXTENSION
 
     template<typename F1,typename F2,typename F3>
- void wait_for_all(F1& f1,F2& f2,F3& f3);
+ void wait_for_all(F1& f1,F2& f2,F3& f3); // EXTENSION
 
     template<typename F1,typename F2,typename F3,typename F4>
- void wait_for_all(F1& f1,F2& f2,F3& f3,F4& f4);
+ void wait_for_all(F1& f1,F2& f2,F3& f3,F4& f4); // EXTENSION
 
     template<typename F1,typename F2,typename F3,typename F4,typename F5>
- void wait_for_all(F1& f1,F2& f2,F3& f3,F4& f4,F5& f5);
+ void wait_for_all(F1& f1,F2& f2,F3& f3,F4& f4,F5& f5); // EXTENSION
 
 [variablelist
 
@@ -1840,18 +2070,62 @@
 
 
 [endsect]
+[/////////////////////////////////////////////////////////////////////////////]
+[section:make_ready_future Non-member function `make_ready_future()` EXTENSION]
+
+ template <typename T>
+ future<typename decay<T>::type> make_ready_future(T&& value); // EXTENSION
+ future<void> make_ready_future(); // EXTENSION
+ template <typename T>
+ future<T> make_ready_future(exception_ptr ex); // EXTENSION
+ template <typename T, typename E>
+ future<T> make_ready_future(E ex); // EXTENSION
+
+[variablelist
+
+[[Effects:] [
+- value prototype: The value that is passed into the function is moved to the shared state of the returned function if it is an rvalue.
+Otherwise the value is copied to the shared state of the returned function.
+
+- exception: The exception that is passed into the function is copied to the shared state of the returned function.
+
+.]]
+
+[[Returns:] [
+
+- a ready future with the value set with `value`
+
+- a ready future with the exception set with `ex`
+
+- a ready future<void> with the value set (void).
+
+]]
+
+[[Postcondition:] [
+
+- Returned future, valid() == true
+
+- Returned future, is_ready() = true
+
+- Returned future, has_value() = true or has_exception() depending on the prototype.
 
-[section:make_future Non-member function `make_future()`]
+]]
+
+]
+
+[endsect]
+[//////////////////////////////////////////////////////////////////]
+[section:make_future Non-member function `make_future()` DEPRECATED]
 
     template <typename T>
- future<typename decay<T>::type> make_future(T&& value); // EXTENSION
- future<void> make_future(); // EXTENSION
+ future<typename decay<T>::type> make_future(T&& value); // DEPRECATED
+ future<void> make_future(); // DEPRECATED
     
 
 [variablelist
 
 [[Effects:] [
-The value that is passed in to the function is moved to the shared state of the returned function if it is an rvalue.
+The value that is passed into the function is moved to the shared state of the returned function if it is an rvalue.
 Otherwise the value is copied to the shared state of the returned function.
 .]]
 
@@ -1871,15 +2145,17 @@
 
 ]]
 
-]
+[[See:] [`make_ready_future()`]]
 
-
+]
+
 [endsect]
-[section:make_shared_future Non-member function `make_shared_future()`]
+[////////////////////////////////////////////////////////////////////////////////]
+[section:make_shared_future Non-member function `make_shared_future()` DEPRECATED]
 
     template <typename T>
- shared_future<typename decay<T>::type> make_shared_future(T&& value); // EXTENSION
- shared_future<void> make_shared_future(); // EXTENSION
+ shared_future<typename decay<T>::type> make_shared_future(T&& value); // DEPRECATED
+ shared_future<void> make_shared_future(); // DEPRECATED
  
 [variablelist
 
@@ -1904,6 +2180,8 @@
 
 ]]
 
+[[See:] [`make_ready_future()` and `future<>::share()`]]
+
 ]
     
 [endsect]

Modified: branches/release/libs/thread/doc/futures.qbk
==============================================================================
--- branches/release/libs/thread/doc/futures.qbk Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/doc/futures.qbk 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -293,7 +293,7 @@
 
 [heading Multiple get]
 
-The second `get()` call in the following example future
+The second `get()` call in the following example is undefined.
 
   void bad_second_use( type arg ) {
       
@@ -369,17 +369,17 @@
 
 [endsect]
 
-[section:make_future Making immediate futures easier]
+[section:make_ready_future Making immediate futures easier]
 
 Some functions may know the value at the point of construction. In these cases the value is immediately available,
-but needs to be returned as a future or shared_future. By using make_future (make_shared_future) a future (shared_future)
+but needs to be returned as a future or shared_future. By using make_ready_future a future
 can be created which holds a pre-computed result in its shared state.
  
 Without these features it is non-trivial to create a future directly from a value.
 First a promise must be created, then the promise is set, and lastly the future is retrieved from the promise.
 This can now be done with one operation.
 
-[heading make_future / make_shared_future]
+[heading make_ready_future]
 
 This function creates a future for a given value. If no value is given then a future<void> is returned.
 This function is primarily useful in cases where sometimes, the return value is immediately available, but sometimes
@@ -389,16 +389,14 @@
 
   boost::future<int> compute(int x)
   {
- if (x == 0) return boost::make_future(0);
- if (x < 0) return boost::make_future(-1);
+ if (x == 0) return boost::make_ready_future(0);
+ if (x < 0) return boost::make_ready_future<int>(std::logic_error("Error"));
     boost::future<int> f1 = boost::async([]() { return x+1; });
     return f1;
   }
   
 There are two variations of this function. The first takes a value of any type, and returns a future of that type.
-The input value is passed to the shared state of the returned future. The second version takes no input and returns a future<void>.
-make_shared_future has the same functionality as make_future, except has a return type of shared_future.
-
+The input value is passed to the shared state of the returned future. The second version takes no input and returns a future<void>.
 
 [endsect]
 
@@ -406,16 +404,16 @@
 
 In asynchronous programming, it is very common for one asynchronous operation, on completion, to invoke a second
 operation and pass data to it. The current C++ standard does not allow one to register a continuation to a future.
-With .then, instead of waiting for the result, a continuation is "attached" to the asynchronous operation, which is
-invoked when the result is ready. Continuations registered using the .then function will help to avoid blocking waits
+With `.then`, instead of waiting for the result, a continuation is "attached" to the asynchronous operation, which is
+invoked when the result is ready. Continuations registered using the `.then` function will help to avoid blocking waits
 or wasting threads on polling, greatly improving the responsiveness and scalability of an application.
 
-future.then provides the ability to sequentially compose two futures by declaring one to be the continuation of another.
-With .then the antecedent future is ready (has a value or exception stored in the shared state) before the continuation
+`future.then()` provides the ability to sequentially compose two futures by declaring one to be the continuation of another.
+With `.then()` the antecedent future is ready (has a value or exception stored in the shared state) before the continuation
 starts as instructed by the lambda function.
 
-In the example below the future<int> f2 is registered to be a continuation of future<int> f1 using the .then member
-function. This operation takes a lambda function which describes how f2 should proceed after f1 is ready.
+In the example below the `future<int>` `f2` is registered to be a continuation of `future<int>` `f1` using the `.then()` member
+function. This operation takes a lambda function which describes how `f2` should proceed after `f1` is ready.
 
 
   #include <boost/thread/future.hpp>
@@ -428,7 +426,7 @@
 
 One key feature of this function is the ability to chain multiple asynchronous operations. In asynchronous programming,
 it's common to define a sequence of operations, in which each continuation executes only when the previous one completes.
-In some cases, the antecedent future produces a value that the continuation accepts as input. By using future.then,
+In some cases, the antecedent future produces a value that the continuation accepts as input. By using `future.then()`,
 creating a chain of continuations becomes straightforward and intuitive:
 
   myFuture.then(...).then(...).then(...).
@@ -441,21 +439,20 @@
 
 Input Parameters:
 
-* Lambda function2: One option which was considered was to follow JavaScript's approach and take two functions, one for
-success and one for error handling. However this option is not viable in C++ as there is no single base type for
-exceptions as there is in JavaScript. The lambda function takes a future as its input which carries the exception
+* Lambda function: One option which can be considered is to take two functions, one for
+success and one for error handling. However this option has not been retained for the moment.
+The lambda function takes a future as its input which carries the exception
 through. This makes propagating exceptions straightforward. This approach also simplifies the chaining of continuations.
-* Scheduler: Providing an overload to .then, to take a scheduler reference places great flexibility over the execution
+* Scheduler: Providing an overload to `.then`, to take a scheduler reference places great flexibility over the execution
 of the future in the programmer's hand. As described above, often taking a launch policy is not sufficient for powerful
 asynchronous operations. The lifetime of the scheduler must outlive the continuation.
 * Launch policy: if the additional flexibility that the scheduler provides is not required.
 
-
 Return values: The decision to return a future was based primarily on the ability to chain multiple continuations using
-.then. This benefit of composability gives the programmer incredible control and flexibility over their code. Returning
-a future object rather than a shared_future is also a much cheaper operation thereby improving performance. A
-shared_future object is not necessary to take advantage of the chaining feature. It is also easy to go from a future
-to a shared_future when needed using future::share().
+`.then()`. This benefit of composability gives the programmer incredible control and flexibility over their code. Returning
+a `future` object rather than a `shared_future` is also a much cheaper operation thereby improving performance. A
+`shared_future` object is not necessary to take advantage of the chaining feature. It is also easy to go from a `future`
+to a `shared_future` when needed using future::share().
 
 
 [endsect]

Modified: branches/release/libs/thread/doc/latch.qbk
==============================================================================
--- branches/release/libs/thread/doc/latch.qbk Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/doc/latch.qbk 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -7,13 +7,19 @@
 
 [section:latches Latches -- EXPERIMENTAL]
 
+[////////////////////]
 [section Introdcution]
 
-Latches are a thread co-ordination mechanism that allow one or more threads to block until one or more threads have reached a point. An individual latch is a reusable object; once the operation has been completed, the threads can re-use the same barrier. It is thus useful for managing repeated tasks handled by multiple threads.
+Latches are a thread co-ordination mechanism that allow one or more threads to block until one or more threads have reached a point.
+
+[/
+An individual latch is a reusable object; once the operation has been completed, the threads can re-use the same barrier. It is thus useful for managing repeated tasks handled by multiple threads.
 
 A completion latch is like a latch that allows to associate a completion function which will be called once the internal counter reaches the value 0 and all the consumer threads have taken care of the notification.
+]
 
 [endsect]
+[////////////////]
 [section Examples]
 
 Sample use cases for the latch include:
@@ -38,7 +44,6 @@
 
 An example of the second use case is shown below. We need to load data and then process it using a number of threads. Loading the data is I/O bound, whereas starting threads and creating data structures is CPU bound. By running these in parallel, throughput can be increased.
 
-
   void DoWork() {
     latch start_latch(1);
     vector<thread*> workers;
@@ -57,6 +62,7 @@
     start_latch.count_down();
     }
 
+[/
 The completion latches can be used to co-ordinate also a set of threads carrying out a repeated task. The number of threads can be adjusted dynamically to respond to changing requirements.
 
 In the example below, a number of threads are performing a multi-stage task. Some tasks may require fewer steps than others, meaning that some threads may finish before others. We reduce the number of threads waiting on the latch when this happens.
@@ -96,8 +102,10 @@
       GetNextStage(tasks);
     }
   }
+]
 
 [endsect]
+[///////////////////////////]
 [section:latch Class `latch`]
 
     #include <boost/thread/latch.hpp>
@@ -119,16 +127,20 @@
         cv_status wait_until(const chrono::time_point<Clock, Duration>& abs_time);
         void count_down();
         void count_down_and_wait();
- void reset(std::size_t count);
 
     };
 
 
+[/
+ void reset(std::size_t count);
+]
+
 A latch maintains an internal counter that is initialized when the latch is created. One or more threads may block waiting until the counter is decremented to 0.
 
 Instances of __latch__ are not copyable or movable.
 
-[section Constructor]
+[///////////////////]
+[section Constructor `latch(std::size_t)`]
 
     latch(std::size_t count);
 
@@ -136,14 +148,15 @@
 
 [[Effects:] [Construct a latch with is initial value for the internal counter.]]
 
-[[Note:] [The counter could be zero and reset later.]]
+[[Note:] [The counter could be zero.]]
 
 [[Throws:] [Nothing.]]
 
 ]
 
 [endsect]
-[section Destructor]
+[//////////////////]
+[section Destructor `~latch()`]
 
     ~latch();
 
@@ -158,7 +171,8 @@
 ]
 
 [endsect]
-[section:wait Member function `wait()`]
+[/////////////////////////////////////]
+[section:wait Member Function `wait()`]
 
     void wait();
 
@@ -178,8 +192,8 @@
 ]
 
 [endsect]
-
-[section:try_wait Member function `try_wait()`]
+[/////////////////////////////////////////////]
+[section:try_wait Member Function `try_wait()`]
 
         bool try_wait();
 
@@ -194,8 +208,8 @@
 ]
 
 [endsect]
-
-[section:wait_for Member function `wait_for() `]
+[//////////////////////////////////////////////]
+[section:wait_for Member Function `wait_for() `]
 
         template <class Rep, class Period>
         cv_status wait_for(const chrono::duration<Rep, Period>& rel_time);
@@ -216,7 +230,8 @@
 ]
 
 [endsect]
-[section:wait_until Member function `wait_until()`]
+[/////////////////////////////////////////////////]
+[section:wait_until Member Function `wait_until()`]
 
         template <class lock_type, class Clock, class Duration>
         cv_status wait_until(const chrono::time_point<Clock, Duration>& abs_time);
@@ -237,7 +252,8 @@
 ]
 
 [endsect]
-[section:count_down Member function `count_down()`]
+[/////////////////////////////////////////////////]
+[section:count_down Member Function `count_down()`]
 
         void count_down();
 
@@ -256,7 +272,8 @@
 ]
 
 [endsect]
-[section:count_down_and_wait Member function `count_down_and_wait()`]
+[///////////////////////////////////////////////////////////////////]
+[section:count_down_and_wait Member Function `count_down_and_wait()`]
 
         void count_down_and_wait();
 
@@ -275,8 +292,9 @@
 ]
 
 [endsect]
-
-[section:reset Member function `reset()`]
+[///////////////////////////////////////]
+[
+[section:reset Member Function `reset()`]
 
     reset( size_t );
 
@@ -293,9 +311,11 @@
 ]
 
 [endsect]
-
+]
 [endsect] [/ latch]
 
+[/
+[//////////////////////////////////////////////////]
 [section:completion_latch Class `completion_latch `]
 
     #include <boost/thread/completion_latch.hpp>
@@ -333,6 +353,7 @@
 
 Only the additional functions are documented.
 
+[/////////////////////]
 [section:c Constructor]
 
     completion_latch(std::size_t count);
@@ -348,6 +369,7 @@
 ]
 
 [endsect]
+[///////////////////////////////////////////////]
 [section:cf Constructor with completion function]
 
         template <typename F>
@@ -368,7 +390,8 @@
 ]
 
 [endsect]
-[section:then Member function `then`]
+[///////////////////////////////////]
+[section:then Member Function `then`]
 
         template <typename F>
         completion_function then(F&& funct);
@@ -391,6 +414,6 @@
 [endsect]
 
 [endsect] [/ completion_latch]
-
+]
 
 [endsect] [/ Latches]

Modified: branches/release/libs/thread/doc/sync_streams.qbk
==============================================================================
--- branches/release/libs/thread/doc/sync_streams.qbk Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/doc/sync_streams.qbk 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -16,6 +16,7 @@
 
 [endsect] [/tutorial]
 
+[/////////////////////]
 [section:ref Reference]
 
   #include <boost/thread/externally_locked_stream.hpp>
@@ -48,7 +49,7 @@
     operator>>(externally_locked_stream<Stream, RecursiveMutex>& mtx, T& arg);
   }
 
-
+[/////////////////////////////////////////]
 [section:stream_guard Class `stream_guard`]
   
   #include <boost/thread/externally_locked_stream.hpp>
@@ -78,6 +79,7 @@
 
 `stream_guard` is a model of __StrictLock.
 
+[//////////////////////////////////////////////////]
 [section:constructor `stream_guard(mutex_type & m)`]
 
 [variablelist
@@ -89,7 +91,7 @@
 ]
 
 [endsect]
-
+[////////////////////////////////////////////////////////////////////////////]
 [section:constructor_adopt `stream_guard(mutex_type & m,boost::adopt_lock_t)`]
 
 [variablelist
@@ -105,8 +107,7 @@
 ]
 
 [endsect]
-
-
+[//////////////////////////////////////////////////////////]
 [section:move_constructor `stream_guard(stream_guard && m)`]
 
 
@@ -119,8 +120,7 @@
 ]
 
 [endsect]
-
-
+[////////////////////////////////////]
 [section:destructor `~stream_guard()`]
 
 [variablelist
@@ -134,8 +134,8 @@
 
 [endsect]
 
-
 [endsect]
+[//////////////////////////////////////////////////////////////////]
 [section:externally_locked_stream Class `externally_locked_stream `]
 
   #include <boost/thread/externally_locked_stream.hpp>
@@ -152,7 +152,6 @@
   
       // Modifiers
       stream_guard<Stream, RecursiveMutex> hold();
- Stream& bypass() const;
 
     };
   }
@@ -162,6 +161,7 @@
 pass a reference to a strict lock object.
 
 
+[////////////////////////////////////////////////////////////////////////]
 [section:constructor `externally_locked_stream(Stream&, RecursiveMutex&)`]
 
 [variablelist
@@ -172,6 +172,7 @@
 
 [endsect]
 
+[/////////////////////]
 [section:hold `hold()`]
 
 [variablelist
@@ -182,6 +183,8 @@
 
 [endsect]
 
+
+
 [endsect]
 
 

Modified: branches/release/libs/thread/doc/synchronized_value.qbk
==============================================================================
--- branches/release/libs/thread/doc/synchronized_value.qbk Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/doc/synchronized_value.qbk 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -6,7 +6,7 @@
  /]
 
 
-[section:synchronized_valuesxxx Synchronized values - EXPERIMENTAL]
+[section:synchronized_valuesxxx Synchronized Values - EXPERIMENTAL]
 
 [warning These features are experimental and subject to change in future versions. There are not too much tests yet, so it is possible that you can find out some trivial bugs :(]
 

Modified: branches/release/libs/thread/doc/thread.qbk
==============================================================================
--- branches/release/libs/thread/doc/thread.qbk Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/doc/thread.qbk 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -8,7 +8,7 @@
 
 [library Thread
     [quickbook 1.5]
- [version 4.1.0]
+ [version 4.2.0]
     [authors [Williams, Anthony] [Botet Escriba, Vicente J.]]
     [copyright 2007-11 Anthony Williams]
     [copyright 2011-13 Vicente J. Botet Escriba]
@@ -239,7 +239,7 @@
 [include condition_variables.qbk]
 [include once.qbk]
 [include barrier.qbk]
-[/include latch.qbk]
+[include latch.qbk]
 [include futures.qbk]
 [/include async_executors.qbk]
 [endsect]
@@ -249,7 +249,7 @@
 
 [section:sds Synchronized Data Structures]
 [include synchronized_value.qbk]
-[/include sync_queues_ref.qbk]
+[include sync_queues_ref.qbk]
 [/include sync_streams.qbk]
 [endsect]
 

Copied: branches/release/libs/thread/example/future_fallback_to.cpp (from r84750, trunk/libs/thread/example/future_fallback_to.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/thread/example/future_fallback_to.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200, copy of r84750, trunk/libs/thread/example/future_fallback_to.cpp)
@@ -0,0 +1,78 @@
+// Copyright (C) 2012-2013 Vicente Botet
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_THREAD_VERSION 4
+#define BOOST_THREAD_USES_LOG
+#define BOOST_THREAD_USES_LOG_THREAD_ID
+
+#include <boost/thread/detail/log.hpp>
+#include <boost/thread/future.hpp>
+#include <boost/assert.hpp>
+#include <exception>
+#include <string>
+
+#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
+
+int p1_ex()
+{
+ BOOST_THREAD_LOG << "P1" << BOOST_THREAD_END_LOG;
+ throw std::logic_error("kk");
+}
+
+int p1()
+{
+ BOOST_THREAD_LOG << "P1" << BOOST_THREAD_END_LOG;
+ return 1;;
+}
+
+int main()
+{
+ BOOST_THREAD_LOG << "<MAIN" << BOOST_THREAD_END_LOG;
+ {
+ try
+ {
+ boost::future<int> f1 = boost::async(boost::launch::async, &p1);
+ boost::future<int> f2 = f1.fallback_to(-1);
+ assert(f2.get()==1);
+ }
+ catch (std::exception& ex)
+ {
+ BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
+ return 1;
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
+ return 2;
+ }
+ }
+ {
+ try
+ {
+ boost::future<int> f1 = boost::async(boost::launch::async, &p1_ex);
+ boost::future<int> f2 = f1.fallback_to(-1);
+ assert(f2.get()==-1);
+ }
+ catch (std::exception& ex)
+ {
+ BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
+ return 1;
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
+ return 2;
+ }
+ }
+ BOOST_THREAD_LOG << "MAIN>" << BOOST_THREAD_END_LOG;
+ return 0;
+}
+#else
+
+int main()
+{
+ return 0;
+}
+#endif

Modified: branches/release/libs/thread/example/future_then.cpp
==============================================================================
--- branches/release/libs/thread/example/future_then.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/example/future_then.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -19,7 +19,26 @@
   return 123;
 }
 
-int p2(boost::future<int>& f)
+int p2(boost::future<int> f)
+{
+ BOOST_THREAD_LOG << "<P2" << BOOST_THREAD_END_LOG;
+ try
+ {
+ return 2 * f.get();
+ }
+ catch (std::exception& ex)
+ {
+ BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
+ BOOST_ASSERT(false);
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
+ BOOST_ASSERT(false);
+ }
+ BOOST_THREAD_LOG << "P2>" << BOOST_THREAD_END_LOG;
+}
+int p2s(boost::shared_future<int> f)
 {
   BOOST_THREAD_LOG << "<P2" << BOOST_THREAD_END_LOG;
   try
@@ -42,6 +61,7 @@
 int main()
 {
   BOOST_THREAD_LOG << "<MAIN" << BOOST_THREAD_END_LOG;
+ {
   try
   {
     boost::future<int> f1 = boost::async(boost::launch::async, &p1);
@@ -58,6 +78,25 @@
     BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
     return 2;
   }
+ }
+ {
+ try
+ {
+ boost::shared_future<int> f1 = boost::async(boost::launch::async, &p1).share();
+ boost::future<int> f2 = f1.then(&p2s);
+ (void)f2.get();
+ }
+ catch (std::exception& ex)
+ {
+ BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
+ return 1;
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
+ return 2;
+ }
+ }
   BOOST_THREAD_LOG << "MAIN>" << BOOST_THREAD_END_LOG;
   return 0;
 }

Copied: branches/release/libs/thread/example/future_unwrap.cpp (from r84750, trunk/libs/thread/example/future_unwrap.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/thread/example/future_unwrap.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200, copy of r84750, trunk/libs/thread/example/future_unwrap.cpp)
@@ -0,0 +1,59 @@
+// Copyright (C) 2012-2013 Vicente Botet
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_THREAD_VERSION 4
+#define BOOST_THREAD_USES_LOG
+#define BOOST_THREAD_USES_LOG_THREAD_ID
+
+#include <boost/thread/detail/log.hpp>
+#include <boost/thread/future.hpp>
+#include <boost/assert.hpp>
+#include <string>
+#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
+
+int p1()
+{
+ BOOST_THREAD_LOG << "P1" << BOOST_THREAD_END_LOG;
+ return 123;
+}
+
+boost::future<int> p2()
+{
+ BOOST_THREAD_LOG << "<P2" << BOOST_THREAD_END_LOG;
+ boost::future<int> f1 = boost::async(boost::launch::async, &p1);
+ BOOST_THREAD_LOG << "P2>" << BOOST_THREAD_END_LOG;
+ return boost::move(f1);
+}
+
+int main()
+{
+ BOOST_THREAD_LOG << "<MAIN" << BOOST_THREAD_END_LOG;
+ try
+ {
+ boost::future<boost::future<int> > outer_future = boost::async(boost::launch::async, &p2);
+ boost::future<int> inner_future = outer_future.unwrap();
+ int i = inner_future.get();
+ BOOST_THREAD_LOG << "i= "<< i << "" << BOOST_THREAD_END_LOG;
+ }
+ catch (std::exception& ex)
+ {
+ BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
+ return 1;
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
+ return 2;
+ }
+ BOOST_THREAD_LOG << "MAIN>" << BOOST_THREAD_END_LOG;
+ return 0;
+}
+#else
+
+int main()
+{
+ return 0;
+}
+#endif

Modified: branches/release/libs/thread/example/lambda_future.cpp
==============================================================================
--- branches/release/libs/thread/example/lambda_future.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/example/lambda_future.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -33,7 +33,7 @@
     }
     {
       boost::future<int> f1 = boost::async(boost::launch::async, []() {return 123;});
- boost::future<int> f2 = f1.then([](boost::future<int>& f) {return 2*f.get(); });
+ boost::future<int> f2 = f1.then([](boost::future<int> f) {return 2*f.get(); });
       int result = f2.get();
       BOOST_THREAD_LOG << "f2 " << result << BOOST_THREAD_END_LOG;
     }

Modified: branches/release/libs/thread/example/make_future.cpp
==============================================================================
--- branches/release/libs/thread/example/make_future.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/example/make_future.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -8,6 +8,16 @@
 #include <boost/thread/future.hpp>
 #include <iostream>
 
+namespace boost
+{
+
+ template <typename T>
+ exception_ptr make_exception_ptr(T v)
+ {
+ return copy_exception(v);
+ }
+}
+
 int p1() { return 5; }
 
 void p() { }
@@ -15,22 +25,23 @@
 #if defined BOOST_THREAD_USES_MOVE
 boost::future<void> void_compute()
 {
- return BOOST_THREAD_MAKE_RV_REF(boost::make_future());
+ return BOOST_THREAD_MAKE_RV_REF(boost::make_ready_future());
 }
 #endif
 
 boost::future<int> compute(int x)
 {
- if (x == 0) return boost::make_future(0);
- if (x < 0) return boost::make_future(-1);
+ if (x == 0) return boost::make_ready_future(0);
+ //if (x < 0) return boost::make_ready_future<int>(boost::make_exception_ptr(std::logic_error("Error")));
+ if (x < 0) return boost::make_ready_future<int>(std::logic_error("Error"));
   //boost::future<int> f1 = boost::async([]() { return x+1; });
   boost::future<int> f1 = boost::async(boost::launch::async, p1);
   return boost::move(f1);
 }
 boost::shared_future<int> shared_compute(int x)
 {
- if (x == 0) return boost::make_shared_future(0);
- if (x < 0) return boost::make_shared_future(-1);
+ if (x == 0) return boost::make_ready_future(0).share();
+ if (x < 0) return boost::make_ready_future<int>(std::logic_error("Error")).share();
   //boost::future<int> f1 = boost::async([]() { return x+1; });
   boost::shared_future<int> f1 = boost::async(p1).share();
   return boost::move(f1);

Modified: branches/release/libs/thread/example/perf_condition_variable.cpp
==============================================================================
--- branches/release/libs/thread/example/perf_condition_variable.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/example/perf_condition_variable.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -143,7 +143,7 @@
   {
     typedef SharedData<Types> S;
 
- auto best_producer_time = std::numeric_limits<Stopwatch::rep>::max();
+ auto best_producer_time = std::numeric_limits<Stopwatch::rep>::max BOOST_PREVENT_MACRO_SUBSTITUTION ();
 
     std::vector<std::thread> consumers
     { consumer_count };
@@ -165,7 +165,7 @@
       for (unsigned i = 0; i < consumer_count; ++i)
         consumers[i].join();
 
- best_producer_time = std::min(best_producer_time, shared_data.producer_time);
+ best_producer_time = std::min BOOST_PREVENT_MACRO_SUBSTITUTION (best_producer_time, shared_data.producer_time);
 
     }
 

Modified: branches/release/libs/thread/example/perf_shared_mutex.cpp
==============================================================================
--- branches/release/libs/thread/example/perf_shared_mutex.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/example/perf_shared_mutex.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -42,7 +42,7 @@
 
 int main()
 {
- boost::chrono::high_resolution_clock::duration best_time(std::numeric_limits<boost::chrono::high_resolution_clock::duration::rep>::max());
+ boost::chrono::high_resolution_clock::duration best_time(std::numeric_limits<boost::chrono::high_resolution_clock::duration::rep>::max BOOST_PREVENT_MACRO_SUBSTITUTION ());
   for (int i =100; i>0; --i) {
     boost::chrono::high_resolution_clock clock;
     boost::chrono::high_resolution_clock::time_point s1 = clock.now();
@@ -61,7 +61,7 @@
   // t13.join();
     boost::chrono::high_resolution_clock::time_point f1 = clock.now();
     //std::cout << " Time spent:" << (f1 - s1) << std::endl;
- best_time = std::min(best_time, f1 - s1);
+ best_time = std::min BOOST_PREVENT_MACRO_SUBSTITUTION (best_time, f1 - s1);
 
   }
   std::cout << "Best Time spent:" << best_time << std::endl;

Modified: branches/release/libs/thread/example/tennis.cpp
==============================================================================
--- branches/release/libs/thread/example/tennis.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/example/tennis.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -4,6 +4,9 @@
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
+#undef BOOST_THREAD_VERSION
+#define BOOST_THREAD_VERSION 2
+
 #include <boost/thread/mutex.hpp>
 #include <boost/thread/condition.hpp>
 #include <boost/thread/thread_only.hpp>

Modified: branches/release/libs/thread/test/Jamfile.v2
==============================================================================
--- branches/release/libs/thread/test/Jamfile.v2 Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/test/Jamfile.v2 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -66,6 +66,14 @@
         #<toolset>darwin-4.6.2:<cxxflags>-Wno-delete-non-virtual-dtor # doesn't work
         <toolset>darwin-4.7.0:<cxxflags>-ansi
         <toolset>darwin-4.7.0:<cxxflags>-Wno-delete-non-virtual-dtor
+ #<toolset>darwin-4.6.2:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.7.1:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.7.2:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.8.0:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.6.2x:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.7.1x:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.7.2x:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.8.0x:<cxxflags>-Wno-unused-local-typedefs
 
         #<toolset>clang-2.8:<cxxflags>-Wno-delete-non-virtual-dtor
         #<toolset>clang-2.8:<cxxflags>-Wno-unused-function
@@ -74,6 +82,8 @@
         <toolset>clang-3.0:<cxxflags>-Wno-delete-non-virtual-dtor
         #<toolset>clang-3.0:<cxxflags>-Wno-unused-function
         #<toolset>clang-3.0:<cxxflags>-Wno-unused-variable
+ #<toolset>clang-3.1:<cxxflags>-Wno-bind-to-temporary-copy
+ #<toolset>clang-3.2:<cxxflags>-Wno-bind-to-temporary-copy
 
 # Note: Some of the remarks from the Intel compiler are disabled
 # remark #193: zero used for undefined preprocessing identifier "XXX"
@@ -221,6 +231,8 @@
           [ thread-test test_condition.cpp ]
           [ thread-test test_once.cpp ]
           [ thread-run test_barrier.cpp ]
+ [ thread-run test_barrier_void_fct.cpp ]
+ [ thread-run test_barrier_size_fct.cpp ]
           [ thread-test test_lock_concept.cpp ]
           [ thread-test test_generic_locks.cpp ]
           [ thread-run test_latch.cpp ]
@@ -342,6 +354,7 @@
           [ thread-run2-noit ./sync/futures/future/default_pass.cpp : future__default_p ]
           [ thread-run2-noit ./sync/futures/future/dtor_pass.cpp : future__dtor_p ]
           [ thread-run2-noit ./sync/futures/future/get_pass.cpp : future__get_p ]
+ [ thread-run2-noit ./sync/futures/future/get_or_pass.cpp : future__get_or_p ]
           [ thread-run2-noit ./sync/futures/future/move_ctor_pass.cpp : future__move_ctor_p ]
           [ thread-run2-noit ./sync/futures/future/move_assign_pass.cpp : future__move_asign_p ]
           [ thread-run2-noit ./sync/futures/future/share_pass.cpp : future__share_p ]
@@ -364,6 +377,7 @@
           [ thread-run2-noit ./sync/futures/shared_future/wait_pass.cpp : shared_future__wait_p ]
           [ thread-run2-noit ./sync/futures/shared_future/wait_for_pass.cpp : shared_future__wait_for_p ]
           [ thread-run2-noit ./sync/futures/shared_future/wait_until_pass.cpp : shared_future__wait_until_p ]
+ [ thread-run2-noit ./sync/futures/shared_future/then_pass.cpp : shared_future__then_p ]
     ;
 
     #explicit ts_packaged_task ;
@@ -616,6 +630,17 @@
           [ thread-run2-noit ./sync/mutual_exclusion/null_mutex/try_lock_until_pass.cpp : null_mutex__try_lock_until_p ]
     ;
 
+ test-suite ts_sync_queue
+ :
+ [ thread-run2-noit ./sync/mutual_exclusion/sync_queue/single_thread_pass.cpp : sync_queue__single_thread_p ]
+ [ thread-run2-noit ./sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp : sync_queue__multi_thread_p ]
+ ;
+
+ test-suite ts_sync_bounded_queue
+ :
+ [ thread-run2-noit ./sync/mutual_exclusion/sync_bounded_queue/single_thread_pass.cpp : sync_bounded_queue__single_thread_p ]
+ [ thread-run2-noit ./sync/mutual_exclusion/sync_bounded_queue/multi_thread_pass.cpp : sync_bounded_queue__multi_thread_p ]
+ ;
 
     #explicit ts_this_thread ;
     test-suite ts_this_thread
@@ -679,8 +704,10 @@
           #[ thread-run ../example/vhh_shared_mutex.cpp ]
           [ thread-run2 ../example/make_future.cpp : ex_make_future ]
           [ thread-run2 ../example/future_then.cpp : ex_future_then ]
- #[ thread-run2-noit ../example/synchronized_value.cpp : ex_synchronized_value ]
- #[ thread-run2-noit ../example/synchronized_person.cpp : ex_synchronized_person ]
+ [ thread-run2 ../example/future_fallback_to.cpp : ex_future_fallback_to ]
+ [ thread-run2 ../example/future_unwrap.cpp : ex_future_unwrap ]
+ [ thread-run2-noit ../example/synchronized_value.cpp : ex_synchronized_value ]
+ [ thread-run2-noit ../example/synchronized_person.cpp : ex_synchronized_person ]
           [ thread-run2-noit ../example/thread_guard.cpp : ex_thread_guard ]
           [ thread-run2-noit ../example/scoped_thread.cpp : ex_scoped_thread ]
           [ thread-run2-noit ../example/strict_lock.cpp : ex_strict_lock ]
@@ -755,11 +782,15 @@
           #[ thread-run test_7720.cpp ]
           #[ thread-run test_7666.cpp ]
           #[ thread-run test_7755.cpp ]
- #[ thread-run ../example/unwrap.cpp ]
           #[ thread-run ../example/perf_condition_variable.cpp ]
           #[ thread-run ../example/perf_shared_mutex.cpp ]
           #[ thread-run ../example/std_async_test.cpp ]
- [ thread-run test_8596.cpp ]
+ #[ thread-run test_8508.cpp ]
+ #[ thread-run test_8586.cpp ]
+ #[ thread-run test_8596.cpp ]
+ #[ thread-run test_8600.cpp ]
+ #[ thread-run2-noit ./sync/mutual_exclusion/sync_bounded_queue/multi_thread_pass.cpp : sync_bounded_queue__multi_thread_p ]
+
     ;
 
 }

Modified: branches/release/libs/thread/test/sync/futures/async/async_pass.cpp
==============================================================================
--- branches/release/libs/thread/test/sync/futures/async/async_pass.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/test/sync/futures/async/async_pass.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -38,18 +38,21 @@
 
 class A
 {
- long data_;
+ long data_;
 
 public:
- typedef long result_type;
+ typedef long result_type;
 
- explicit A(long i) : data_(i) {}
+ explicit A(long i) :
+ data_(i)
+ {
+ }
 
- long operator()() const
- {
- boost::this_thread::sleep_for(ms(200));
- return data_;
- }
+ long operator()() const
+ {
+ boost::this_thread::sleep_for(ms(200));
+ return data_;
+ }
 };
 
 class MoveOnly
@@ -59,37 +62,38 @@
 
   int value;
 
- BOOST_THREAD_MOVABLE_ONLY(MoveOnly)
+BOOST_THREAD_MOVABLE_ONLY(MoveOnly)
   MoveOnly()
   {
- value=0;
- }
- MoveOnly(BOOST_THREAD_RV_REF(MoveOnly))
- {
- value=1;
- }
- MoveOnly& operator=(BOOST_THREAD_RV_REF(MoveOnly))
- {
- value=2;
- return *this;
+ value = 0;
   }
+ MoveOnly( BOOST_THREAD_RV_REF(MoveOnly))
+ {
+ value = 1;
+ }
+ MoveOnly& operator=(BOOST_THREAD_RV_REF(MoveOnly))
+ {
+ value = 2;
+ return *this;
+ }
+
+ int operator()()
+ {
+ boost::this_thread::sleep_for(ms(200));
+ return 3;
+ }
+ template <typename OS>
+ friend OS& operator<<(OS& os, MoveOnly const& v)
+ {
+ os << v.value;
+ return os;
+ }
+ };
 
- int operator()()
- {
- boost::this_thread::sleep_for(ms(200));
- return 3;
- }
- template <typename OS>
- friend OS& operator<<(OS& os, MoveOnly const& v)
- {
- os << v.value;
- return os;
+ namespace boost
+ {
+BOOST_THREAD_DCL_MOVABLE (MoveOnly)
   }
-};
-
-namespace boost {
-BOOST_THREAD_DCL_MOVABLE(MoveOnly)
-}
 
 int f0()
 {
@@ -113,7 +117,7 @@
 boost::interprocess::unique_ptr<int, boost::default_delete<int> > f3_0()
 {
   boost::this_thread::sleep_for(ms(200));
- boost::interprocess::unique_ptr<int, boost::default_delete<int> > r((new int(3)));
+ boost::interprocess::unique_ptr<int, boost::default_delete<int> > r( (new int(3)));
   return boost::move(r);
 }
 MoveOnly f3_1()
@@ -139,299 +143,404 @@
 
 int main()
 {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<int> f = boost::async(f0);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(f.get() == 3);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(300));
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::future<int> f = boost::async(f0);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
 
   }
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<int> f = boost::async(boost::launch::async, f0);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(f.get() == 3);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::shared_future<int> f = boost::async(f0).share();
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
 
+ }
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+ {
+ try
+ {
+ boost::future<int> f = boost::async(boost::launch::async, f0);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ << "[" << __LINE__ << "] " << (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
+ BOOST_TEST(false && "exception thrown");
+ }
+ catch (...)
+ {
+ BOOST_TEST(false && "exception thrown");
+ }
 
   }
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<long> f = boost::async(boost::launch::async, A(3));
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(f.get() == 3);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::future<long> f = boost::async(boost::launch::async, A(3));
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ << "[" << __LINE__ << "] " << (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
 
   }
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<int> f = boost::async(boost::launch::async, BOOST_THREAD_MAKE_RV_REF(MoveOnly()));
-// boost::this_thread::sleep_for(ms(300));
-// Clock::time_point t0 = Clock::now();
-// BOOST_TEST(f.get() == 3);
-// Clock::time_point t1 = Clock::now();
-// BOOST_TEST(t1 - t0 < ms(200));
-// std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::future<int> f = boost::async(boost::launch::async, BOOST_THREAD_MAKE_RV_REF(MoveOnly()));
+ // boost::this_thread::sleep_for(ms(300));
+ // Clock::time_point t0 = Clock::now();
+ // BOOST_TEST(f.get() == 3);
+ // Clock::time_point t1 = Clock::now();
+ // BOOST_TEST(t1 - t0 < ms(300));
+ // std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<int> f = boost::async(boost::launch::any, f0);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(f.get() == 3);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::future<int> f = boost::async(boost::launch::any, f0);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ << "[" << __LINE__ << "] " << (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
   std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
   {
- try {
- boost::future<int> f = boost::async(boost::launch::deferred, f0);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(f.get() == 3);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 > ms(100));
- } catch (std::exception& ex) {
+ try
+ {
+ boost::future<int> f = boost::async(boost::launch::deferred, f0);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 > ms(100));
+ }
+ catch (std::exception& ex)
+ {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
 #endif
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<int&> f = boost::async(f1);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(&f.get() == &i);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::future<int&> f = boost::async(f1);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ << "[" << __LINE__ << "] " << (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<int&> f = boost::async(boost::launch::async, f1);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(&f.get() == &i);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::future<int&> f = boost::async(boost::launch::async, f1);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ << "[" << __LINE__ << "] " << (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<int&> f = boost::async(boost::launch::any, f1);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(&f.get() == &i);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::future<int&> f = boost::async(boost::launch::any, f1);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ << "[" << __LINE__ << "] " << (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
   std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
   {
- try {
- boost::future<int&> f = boost::async(boost::launch::deferred, f1);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(&f.get() == &i);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 > ms(100));
- } catch (std::exception& ex) {
+ try
+ {
+ boost::future<int&> f = boost::async(boost::launch::deferred, f1);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 > ms(100));
+ }
+ catch (std::exception& ex)
+ {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
 #endif
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<void> f = boost::async(f2);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- f.get();
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::future<void> f = boost::async(f2);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ << "[" << __LINE__ << "] " << (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<void> f = boost::async(boost::launch::async, f2);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- f.get();
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::future<void> f = boost::async(boost::launch::async, f2);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ << "[" << __LINE__ << "] " << (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<void> f = boost::async(boost::launch::any, f2);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- f.get();
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::future<void> f = boost::async(boost::launch::any, f2);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ << "[" << __LINE__ << "] " << (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
   std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
   {
- try {
- boost::future<void> f = boost::async(boost::launch::deferred, f2);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- f.get();
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 > ms(100));
- } catch (std::exception& ex) {
+ try
+ {
+ boost::future<void> f = boost::async(boost::launch::deferred, f2);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 > ms(100));
+ }
+ catch (std::exception& ex)
+ {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
 #endif
 
-
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
+ try
+ {
       boost::future<MoveOnly> f = boost::async(&f3_1);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(f.get().value == 1);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get().value == 1);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
+ try
+ {
       boost::future<MoveOnly> f;
       f = boost::async(&f3_1);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(f.get().value == 1);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(f.get().value == 1);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
   {
- try {
- boost::future<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = boost::async(&f3_0);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(*f.get() == 3);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
- std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
+ try
+ {
+ boost::future<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = boost::async(&f3_0);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(*f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ << "[" << __LINE__ << "] " << (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
@@ -439,35 +548,45 @@
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
   std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
   {
- try {
- boost::future<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = boost::async(boost::launch::async, &f3, 3);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(*f.get() == 3);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
+ try
+ {
+ boost::future<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = boost::async(boost::launch::async, &f3, 3);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(*f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
   std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
   {
- try {
- boost::future<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = boost::async(&f3, 3);
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(*f.get() == 3);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
+ try
+ {
+ boost::future<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = boost::async(&f3, 3);
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(*f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
@@ -476,35 +595,45 @@
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
   std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
   {
- try {
- boost::future<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = boost::async(boost::launch::async, &f4, boost::interprocess::unique_ptr<int, boost::default_delete<int> >(new int(3)));
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(*f.get() == 3);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
+ try
+ {
+ boost::future<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = boost::async(boost::launch::async, &f4, boost::interprocess::unique_ptr<int, boost::default_delete<int> >(new int(3)));
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(*f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }
   std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
   {
- try {
- boost::future<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = boost::async(&f4, boost::interprocess::unique_ptr<int, boost::default_delete<int> >(new int(3)));
- boost::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- BOOST_TEST(*f.get() == 3);
- Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(200));
- std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
- } catch (std::exception& ex) {
+ try
+ {
+ boost::future<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = boost::async(&f4, boost::interprocess::unique_ptr<int, boost::default_delete<int> >(new int(3)));
+ boost::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ BOOST_TEST(*f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ BOOST_TEST(t1 - t0 < ms(300));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
+ }
+ catch (std::exception& ex)
+ {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
- } catch (...) {
+ }
+ catch (...)
+ {
       BOOST_TEST(false && "exception thrown");
     }
   }

Copied: branches/release/libs/thread/test/sync/futures/future/get_or_pass.cpp (from r84750, trunk/libs/thread/test/sync/futures/future/get_or_pass.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/thread/test/sync/futures/future/get_or_pass.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200, copy of r84750, trunk/libs/thread/test/sync/futures/future/get_or_pass.cpp)
@@ -0,0 +1,182 @@
+// Copyright (C) 2013 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/future.hpp>
+
+// class future<R>
+
+// R future::get_or(R&&);
+// R& future<R&>::get_or(R&);
+
+#define BOOST_THREAD_VERSION 4
+#define BOOST_THREAD_USES_LOG
+#define BOOST_THREAD_USES_LOG_THREAD_ID
+#include <boost/thread/detail/log.hpp>
+
+#include <boost/thread/future.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#if defined BOOST_THREAD_USES_CHRONO
+
+namespace boost
+{
+template <typename T>
+struct wrap
+{
+ wrap(T const& v) : value(v){}
+ T value;
+
+};
+
+template <typename T>
+exception_ptr make_exception_ptr(T v) {
+ return copy_exception(wrap<T>(v));
+}
+}
+
+void func1(boost::promise<int> p)
+{
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
+ p.set_value(3);
+}
+
+void func2(boost::promise<int> p)
+{
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
+ p.set_exception(boost::make_exception_ptr(3));
+}
+
+int j = 0;
+
+void func3(boost::promise<int&> p)
+{
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
+ j = 5;
+ p.set_value(j);
+}
+
+void func4(boost::promise<int&> p)
+{
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
+ p.set_exception(boost::make_exception_ptr(3.5));
+}
+
+void func5(boost::promise<void> p)
+{
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
+ p.set_value();
+}
+
+void func6(boost::promise<void> p)
+{
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
+ p.set_exception(boost::make_exception_ptr(4));
+}
+
+
+int main()
+{
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ {
+ typedef int T;
+ {
+ boost::promise<T> p;
+ boost::future<T> f = p.get_future();
+#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+ boost::thread(func1, boost::move(p)).detach();
+#else
+ p.set_value(3);
+#endif
+ BOOST_TEST(f.valid());
+ BOOST_TEST(f.get_or(4) == 3);
+#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
+ BOOST_TEST(!f.valid());
+#endif
+ }
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ {
+ boost::promise<T> p;
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ boost::future<T> f = p.get_future();
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+ boost::thread(func2, boost::move(p)).detach();
+#else
+ p.set_exception(boost::make_exception_ptr(3));
+#endif
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ try
+ {
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ BOOST_TEST(f.valid());
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ BOOST_TEST(f.get_or(4) == 4);
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ BOOST_TEST(false);
+ }
+#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ BOOST_TEST(!f.valid());
+#endif
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ }
+ }
+// BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+// {
+// typedef int& T;
+// {
+// boost::promise<T> p;
+// boost::future<T> f = p.get_future();
+//#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+// boost::thread(func3, boost::move(p)).detach();
+//#else
+// int j=5;
+// p.set_value(j);
+//#endif
+// BOOST_TEST(f.valid());
+// int k=4;
+// BOOST_TEST(f.get_or(k) == 5);
+//#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
+// BOOST_TEST(!f.valid());
+//#endif
+// }
+// BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+// {
+// boost::promise<T> p;
+// boost::future<T> f = p.get_future();
+//#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+// boost::thread(func4, boost::move(p)).detach();
+//#else
+// p.set_exception(boost::make_exception_ptr(3.5));
+//#endif
+// try
+// {
+// BOOST_TEST(f.valid());
+// int j=4;
+// BOOST_TEST(f.get_or(j) == 4);
+// }
+// catch (...)
+// {
+// BOOST_TEST(false);
+// }
+//#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
+// BOOST_TEST(!f.valid());
+//#endif
+// }
+// }
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+
+
+ return boost::report_errors();
+}
+
+#else
+#error "Test not applicable: BOOST_THREAD_USES_CHRONO not defined for this platform as not supported"
+#endif

Modified: branches/release/libs/thread/test/sync/futures/future/then_pass.cpp
==============================================================================
--- branches/release/libs/thread/test/sync/futures/future/then_pass.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/test/sync/futures/future/then_pass.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -20,6 +20,7 @@
 
 #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
 
+
 int p1()
 {
   BOOST_THREAD_LOG << "p1 < " << BOOST_THREAD_END_LOG;
@@ -28,7 +29,7 @@
   return 1;
 }
 
-int p2(boost::future<int>& f)
+int p2(boost::future<int> f)
 {
   BOOST_THREAD_LOG << "p2 <" << &f << BOOST_THREAD_END_LOG;
   BOOST_TEST(f.valid());
@@ -38,14 +39,25 @@
   return 2 * i;
 }
 
+void p3(boost::future<int> f)
+{
+ BOOST_THREAD_LOG << "p3 <" << &f << BOOST_THREAD_END_LOG;
+ BOOST_TEST(f.valid());
+ int i = f.get();
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
+ BOOST_THREAD_LOG << "p3 <" << &f << " " <<i << BOOST_THREAD_END_LOG;
+ return;
+}
+
 int main()
 {
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
   {
- BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
     boost::future<int> f1 = boost::async(boost::launch::async, &p1);
     BOOST_TEST(f1.valid());
     boost::future<int> f2 = f1.then(&p2);
     BOOST_TEST(f2.valid());
+ BOOST_TEST(! f1.valid());
     try
     {
       BOOST_TEST(f2.get()==2);
@@ -63,6 +75,27 @@
   }
   BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
   {
+ boost::future<int> f1 = boost::async(boost::launch::async, &p1);
+ BOOST_TEST(f1.valid());
+ boost::future<void> f2 = f1.then(&p3);
+ BOOST_TEST(f2.valid());
+ try
+ {
+ f2.wait();
+ }
+ catch (std::exception& ex)
+ {
+ BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
+ BOOST_TEST(false);
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
+ BOOST_TEST(false);
+ }
+ }
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ {
     boost::future<int> f2 = boost::async(p1).then(&p2);
     BOOST_TEST(f2.get()==2);
   }

Modified: branches/release/libs/thread/test/sync/futures/packaged_task/func_ctor_pass.cpp
==============================================================================
--- branches/release/libs/thread/test/sync/futures/packaged_task/func_ctor_pass.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/test/sync/futures/packaged_task/func_ctor_pass.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -26,23 +26,32 @@
 
 #if BOOST_THREAD_VERSION == 4
 #define BOOST_THREAD_DETAIL_SIGNATURE double()
+#define BOOST_THREAD_DETAIL_VOID_SIGNATURE void()
 #else
 #define BOOST_THREAD_DETAIL_SIGNATURE double
+#define BOOST_THREAD_DETAIL_VOID_SIGNATURE void
 #endif
 
 #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
 #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
 #define BOOST_THREAD_DETAIL_SIGNATURE_2 double(int, char)
 #define BOOST_THREAD_DETAIL_SIGNATURE_2_RES 5 + 3 +'a'
+#define BOOST_THREAD_DETAIL_VOID_SIGNATURE_2 void(int)
 #else
 #define BOOST_THREAD_DETAIL_SIGNATURE_2 double()
 #define BOOST_THREAD_DETAIL_SIGNATURE_2_RES 5
+#define BOOST_THREAD_DETAIL_VOID_SIGNATURE_2 void()
 #endif
 #else
 #define BOOST_THREAD_DETAIL_SIGNATURE_2 double
 #define BOOST_THREAD_DETAIL_SIGNATURE_2_RES 5
+#define BOOST_THREAD_DETAIL_VOID_SIGNATURE_2 void
 #endif
 
+void void_fct()
+{
+ return;
+}
 double fct()
 {
   return 5.0;
@@ -95,6 +104,8 @@
   {
   }
 
+ void operator()(int) const
+ { }
   long operator()() const
   { return data_;}
   long operator()(long i, long j) const
@@ -134,6 +145,8 @@
   {
   }
 
+ void operator()(int) const
+ { }
   long operator()() const
   { return data_;}
   long operator()(long i, long j) const
@@ -170,6 +183,8 @@
   {
   }
 
+ void operator()(int) const
+ { }
   long operator()() const
   { return data_;}
   long operator()(long i, long j) const
@@ -180,6 +195,7 @@
 int main()
 {
   {
+ A::reset();
       boost::packaged_task<BOOST_THREAD_DETAIL_SIGNATURE_2> p(BOOST_THREAD_MAKE_RV_REF(A(5)));
       BOOST_TEST(p.valid());
       boost::future<double> f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
@@ -204,7 +220,6 @@
       BOOST_TEST_EQ(A::n_copies, 1);
       BOOST_TEST_EQ(A::n_moves, 0);
   }
-
   {
     A::reset();
       const A a(5);
@@ -217,6 +232,37 @@
       BOOST_TEST_EQ(A::n_copies, 1);
       BOOST_TEST_EQ(A::n_moves, 0);
   }
+#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+ {
+ A::reset();
+ boost::packaged_task<BOOST_THREAD_DETAIL_VOID_SIGNATURE_2> p(BOOST_THREAD_MAKE_RV_REF(A(5)));
+ BOOST_TEST(p.valid());
+ boost::future<void> f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
+ p(1);
+ BOOST_TEST(A::n_copies == 0);
+ BOOST_TEST_EQ(A::n_moves, 1);
+ }
+ {
+ A::reset();
+ A a(5);
+ boost::packaged_task<BOOST_THREAD_DETAIL_VOID_SIGNATURE_2> p(a);
+ BOOST_TEST(p.valid());
+ boost::future<void> f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
+ p(1);
+ BOOST_TEST_EQ(A::n_copies, 1);
+ BOOST_TEST_EQ(A::n_moves, 0);
+ }
+ {
+ A::reset();
+ const A a(5);
+ boost::packaged_task<BOOST_THREAD_DETAIL_VOID_SIGNATURE_2> p(a);
+ BOOST_TEST(p.valid());
+ boost::future<void> f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
+ p(1);
+ BOOST_TEST_EQ(A::n_copies, 1);
+ BOOST_TEST_EQ(A::n_moves, 0);
+ }
+#endif
   {
     M::reset();
       boost::packaged_task<BOOST_THREAD_DETAIL_SIGNATURE_2> p(BOOST_THREAD_MAKE_RV_REF(M(5)));
@@ -241,7 +287,25 @@
       BOOST_TEST(f.get() == 5.0);
       BOOST_TEST_EQ(M::n_moves, 1);
   }
-
+#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+ {
+ M::reset();
+ boost::packaged_task<BOOST_THREAD_DETAIL_VOID_SIGNATURE_2> p(BOOST_THREAD_MAKE_RV_REF(M(5)));
+ BOOST_TEST(p.valid());
+ boost::future<void> f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
+ p(1);
+ BOOST_TEST_EQ(M::n_moves, 1);
+ }
+ {
+ M::reset();
+ M a(5);
+ boost::packaged_task<BOOST_THREAD_DETAIL_VOID_SIGNATURE_2> p(boost::move(a));
+ BOOST_TEST(p.valid());
+ boost::future<void> f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
+ p(1);
+ BOOST_TEST_EQ(M::n_moves, 1);
+ }
+#endif
   {
     C::reset();
       C a(5);
@@ -265,6 +329,33 @@
       BOOST_TEST(f.get() == 5.0);
       BOOST_TEST_EQ(C::n_copies, 1);
   }
+#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+ {
+ C::reset();
+ C a(5);
+ boost::packaged_task<BOOST_THREAD_DETAIL_VOID_SIGNATURE_2> p(a);
+ BOOST_TEST(p.valid());
+ boost::future<void> f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
+ p(1);
+ BOOST_TEST_EQ(C::n_copies, 1);
+ }
+
+ {
+ C::reset();
+ const C a(5);
+ boost::packaged_task<BOOST_THREAD_DETAIL_VOID_SIGNATURE_2> p(a);
+ BOOST_TEST(p.valid());
+ boost::future<void> f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
+ p(1);
+ BOOST_TEST_EQ(C::n_copies, 1);
+ }
+#endif
+ {
+ boost::packaged_task<BOOST_THREAD_DETAIL_VOID_SIGNATURE> p(void_fct);
+ BOOST_TEST(p.valid());
+ boost::future<void> f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
+ p();
+ }
   {
       boost::packaged_task<BOOST_THREAD_DETAIL_SIGNATURE> p(fct);
       BOOST_TEST(p.valid());

Modified: branches/release/libs/thread/test/sync/futures/promise/default_pass.cpp
==============================================================================
--- branches/release/libs/thread/test/sync/futures/promise/default_pass.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/test/sync/futures/promise/default_pass.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -38,9 +38,7 @@
   }
   {
       boost::promise<void> p;
- std::cout << __LINE__ << std::endl;
       boost::future<void> f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
- std::cout << __LINE__ << std::endl;
       BOOST_TEST(f.valid());
   }
 

Copied and modified: branches/release/libs/thread/test/sync/futures/shared_future/then_pass.cpp (from r84588, trunk/libs/thread/test/sync/futures/shared_future/then_pass.cpp)
==============================================================================
--- trunk/libs/thread/test/sync/futures/shared_future/then_pass.cpp Fri May 31 20:44:12 2013 (r84588, copy source)
+++ branches/release/libs/thread/test/sync/futures/shared_future/then_pass.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -28,7 +28,7 @@
   return 1;
 }
 
-int p2(boost::shared_future<int>& f)
+int p2(boost::shared_future<int> f)
 {
   BOOST_THREAD_LOG << "p2 <" << &f << BOOST_THREAD_END_LOG;
   BOOST_TEST(f.valid());
@@ -38,10 +38,20 @@
   return 2 * i;
 }
 
+void p3(boost::shared_future<int> f)
+{
+ BOOST_THREAD_LOG << "p3 <" << &f << BOOST_THREAD_END_LOG;
+ BOOST_TEST(f.valid());
+ int i = f.get();
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
+ BOOST_THREAD_LOG << "p3 <" << &f << " " << i << BOOST_THREAD_END_LOG;
+ return ;
+}
+
 int main()
 {
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
   {
- BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
     boost::shared_future<int> f1 = boost::async(boost::launch::async, &p1).share();
     BOOST_TEST(f1.valid());
     boost::future<int> f2 = f1.then(&p2);
@@ -63,6 +73,27 @@
   }
   BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
   {
+ boost::shared_future<int> f1 = boost::async(boost::launch::async, &p1).share();
+ BOOST_TEST(f1.valid());
+ boost::future<void> f2 = f1.then(&p3);
+ BOOST_TEST(f2.valid());
+ try
+ {
+ f2.wait();
+ }
+ catch (std::exception& ex)
+ {
+ BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
+ BOOST_TEST(false);
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
+ BOOST_TEST(false);
+ }
+ }
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ {
     boost::future<int> f2 = boost::async(p1).share().then(&p2);
     BOOST_TEST(f2.get()==2);
   }

Copied: branches/release/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/multi_thread_pass.cpp (from r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/multi_thread_pass.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/multi_thread_pass.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200, copy of r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/multi_thread_pass.cpp)
@@ -0,0 +1,252 @@
+// Copyright (C) 2013 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/sync_bounded_queue.hpp>
+
+// class sync_queue<T>
+
+// push || pull;
+
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/sync_bounded_queue.hpp>
+#include <boost/thread/future.hpp>
+#include <boost/thread/barrier.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+struct call_push
+{
+ boost::sync_bounded_queue<int> &q_;
+ boost::barrier& go_;
+
+ call_push(boost::sync_bounded_queue<int> &q, boost::barrier &go) :
+ q_(q), go_(go)
+ {
+ }
+ typedef void result_type;
+ void operator()()
+ {
+ go_.count_down_and_wait();
+ q_.push(42);
+
+ }
+};
+
+struct call_push_2
+{
+ boost::sync_bounded_queue<int> &q_;
+ boost::barrier& go_;
+ boost::barrier& end_;
+
+ call_push_2(boost::sync_bounded_queue<int> &q, boost::barrier &go, boost::barrier &end) :
+ q_(q), go_(go), end_(end)
+ {
+ }
+ typedef void result_type;
+ void operator()()
+ {
+ go_.count_down_and_wait();
+ q_.push(42);
+ end_.count_down_and_wait();
+
+ }
+};
+
+struct call_pull
+{
+ boost::sync_bounded_queue<int> &q_;
+ boost::barrier& go_;
+
+ call_pull(boost::sync_bounded_queue<int> &q, boost::barrier &go) :
+ q_(q), go_(go)
+ {
+ }
+ typedef int result_type;
+ int operator()()
+ {
+ go_.count_down_and_wait();
+ return q_.pull();
+ }
+};
+
+void test_concurrent_push_and_pull_on_empty_queue()
+{
+ boost::sync_bounded_queue<int> q(4);
+
+ boost::barrier go(2);
+
+ boost::future<void> push_done;
+ boost::future<int> pull_done;
+
+ try
+ {
+ push_done=boost::async(boost::launch::async,
+#if ! defined BOOST_NO_CXX11_LAMBDAS
+ [&q,&go]()
+ {
+ go.wait();
+ q.push(42);
+ }
+#else
+ call_push(q,go)
+#endif
+ );
+ pull_done=boost::async(boost::launch::async,
+#if ! defined BOOST_NO_CXX11_LAMBDAS
+ [&q,&go]() -> int
+ {
+ go.wait();
+ return q.pull();
+ }
+#else
+ call_pull(q,go)
+#endif
+ );
+
+ push_done.get();
+ BOOST_TEST_EQ(pull_done.get(), 42);
+ BOOST_TEST(q.empty());
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+void test_concurrent_push_on_empty_queue()
+{
+ boost::sync_bounded_queue<int> q(4);
+ const unsigned int n = 3;
+ boost::barrier go(n);
+ boost::future<void> push_done[n];
+
+ try
+ {
+ for (unsigned int i =0; i< n; ++i)
+ push_done[i]=boost::async(boost::launch::async,
+#if ! defined BOOST_NO_CXX11_LAMBDAS
+ [&q,&go]()
+ {
+ go.wait();
+ q.push(42);
+ }
+#else
+ call_push(q,go)
+#endif
+ );
+
+ for (unsigned int i = 0; i < n; ++i)
+ push_done[i].get();
+
+ BOOST_TEST(!q.empty());
+ for (unsigned int i =0; i< n; ++i)
+ BOOST_TEST_EQ(q.pull(), 42);
+ BOOST_TEST(q.empty());
+
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+void test_concurrent_push_on_full_queue()
+{
+ const unsigned int size = 2;
+ boost::sync_bounded_queue<int> q(size);
+ const unsigned int n = 2*size;
+ boost::barrier go(n);
+ boost::barrier end(size+1);
+ boost::future<void> push_done[n];
+
+ try
+ {
+ for (unsigned int i =0; i< n; ++i)
+ push_done[i]=boost::async(boost::launch::async,
+#if ! defined BOOST_NO_CXX11_LAMBDAS
+ [&q,&go,&end]()
+ {
+ go.wait();
+ q.push(42);
+ end.wait();
+ }
+#else
+ call_push_2(q,go,end)
+#endif
+ );
+
+ end.wait();
+ BOOST_TEST(!q.empty());
+ BOOST_TEST(q.full());
+ for (unsigned int i =0; i< size; ++i)
+ BOOST_TEST_EQ(q.pull(), 42);
+ end.wait();
+
+ for (unsigned int i = 0; i < n; ++i)
+ push_done[i].get();
+
+ BOOST_TEST(!q.empty());
+ for (unsigned int i =0; i< size; ++i)
+ BOOST_TEST_EQ(q.pull(), 42);
+ BOOST_TEST(q.empty());
+
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+void test_concurrent_pull_on_queue()
+{
+ boost::sync_bounded_queue<int> q(4);
+ const unsigned int n = 3;
+ boost::barrier go(n);
+
+ boost::future<int> pull_done[n];
+
+ try
+ {
+ for (unsigned int i =0; i< n; ++i)
+ q.push(42);
+
+ for (unsigned int i =0; i< n; ++i)
+ pull_done[i]=boost::async(boost::launch::async,
+#if ! defined BOOST_NO_CXX11_LAMBDAS
+ [&q,&go]() -> int
+ {
+ go.wait();
+ return q.pull();
+ }
+#else
+ call_pull(q,go)
+#endif
+ );
+
+ for (unsigned int i = 0; i < n; ++i)
+ BOOST_TEST_EQ(pull_done[i].get(), 42);
+ BOOST_TEST(q.empty());
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+int main()
+{
+ test_concurrent_push_and_pull_on_empty_queue();
+ test_concurrent_push_on_empty_queue();
+ test_concurrent_push_on_full_queue();
+ test_concurrent_pull_on_queue();
+
+ return boost::report_errors();
+}
+

Copied: branches/release/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/single_thread_pass.cpp (from r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/single_thread_pass.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/single_thread_pass.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200, copy of r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_bounded_queue/single_thread_pass.cpp)
@@ -0,0 +1,226 @@
+// Copyright (C) 2013 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/sync_bounded_queue.hpp>
+
+// class sync_bounded_queue<T>
+
+// sync_bounded_queue();
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/sync_bounded_queue.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ // default queue invariants
+ boost::sync_bounded_queue<int> q(2);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST_EQ(q.capacity(), 2u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_pull fails
+ boost::sync_bounded_queue<int> q(2);
+ int i;
+ BOOST_TEST(! q.try_pull(i));
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_pull fails
+ boost::sync_bounded_queue<int> q(2);
+ BOOST_TEST(! q.try_pull());
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push rvalue succeeds
+ boost::sync_bounded_queue<int> q(2);
+ q.push(1);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push rvalue succeeds
+ boost::sync_bounded_queue<int> q(2);
+ q.push(1);
+ q.push(2);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST( q.full());
+ BOOST_TEST_EQ(q.size(), 2u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push value succeeds
+ boost::sync_bounded_queue<int> q(2);
+ int i;
+ q.push(i);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push rvalue succeeds
+ boost::sync_bounded_queue<int> q(2);
+ BOOST_TEST(q.try_push(1));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push value succeeds
+ boost::sync_bounded_queue<int> q(2);
+ int i;
+ BOOST_TEST(q.try_push(i));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push rvalue succeeds
+ boost::sync_bounded_queue<int> q(2);
+ BOOST_TEST(q.try_push(boost::no_block, 1));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue pull succeed
+ boost::sync_bounded_queue<int> q(2);
+ q.push(1);
+ int i;
+ q.pull(i);
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue pull succeed
+ boost::sync_bounded_queue<int> q(2);
+ q.push(1);
+ int i = q.pull();
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue try_pull succeed
+ boost::sync_bounded_queue<int> q(2);
+ q.push(1);
+ int i;
+ BOOST_TEST(q.try_pull(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue try_pull succeed
+ boost::sync_bounded_queue<int> q(2);
+ q.push(1);
+ int i;
+ BOOST_TEST(q.try_pull(boost::no_block, i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue try_pull succeed
+ boost::sync_bounded_queue<int> q(2);
+ q.push(1);
+ boost::shared_ptr<int> i = q.try_pull();
+ BOOST_TEST_EQ(*i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // full queue try_push rvalue fails
+ boost::sync_bounded_queue<int> q(2);
+ q.push(1);
+ q.push(2);
+ BOOST_TEST(! q.try_push(3));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST( q.full());
+ BOOST_TEST_EQ(q.size(), 2u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // full queue try_push succeeds
+ boost::sync_bounded_queue<int> q(2);
+ q.push(1);
+ q.push(2);
+ BOOST_TEST(q.try_pull());
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+
+ {
+ // closed invariants
+ boost::sync_bounded_queue<int> q(2);
+ q.close();
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // closed queue push fails
+ boost::sync_bounded_queue<int> q(2);
+ q.close();
+ try {
+ q.push(1);
+ BOOST_TEST(false);
+ } catch (...) {
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ }
+ {
+ // 1-element closed queue pull succeed
+ boost::sync_bounded_queue<int> q(2);
+ q.push(1);
+ q.close();
+ int i;
+ q.pull(i);
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+
+ return boost::report_errors();
+}
+

Copied: branches/release/libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp (from r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200, copy of r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp)
@@ -0,0 +1,185 @@
+// Copyright (C) 2013 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/sync_queue.hpp>
+
+// class sync_queue<T>
+
+// push || pull;
+
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/sync_queue.hpp>
+#include <boost/thread/future.hpp>
+#include <boost/thread/barrier.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+struct call_push
+{
+ boost::sync_queue<int> &q_;
+ boost::barrier& go_;
+
+ call_push(boost::sync_queue<int> &q, boost::barrier &go) :
+ q_(q), go_(go)
+ {
+ }
+ typedef void result_type;
+ void operator()()
+ {
+ go_.count_down_and_wait();
+ q_.push(42);
+
+ }
+};
+
+struct call_pull
+{
+ boost::sync_queue<int> &q_;
+ boost::barrier& go_;
+
+ call_pull(boost::sync_queue<int> &q, boost::barrier &go) :
+ q_(q), go_(go)
+ {
+ }
+ typedef int result_type;
+ int operator()()
+ {
+ go_.count_down_and_wait();
+ return q_.pull();
+ }
+};
+
+void test_concurrent_push_and_pull_on_empty_queue()
+{
+ boost::sync_queue<int> q;
+
+ boost::barrier go(2);
+
+ boost::future<void> push_done;
+ boost::future<int> pull_done;
+
+ try
+ {
+ push_done=boost::async(boost::launch::async,
+#if ! defined BOOST_NO_CXX11_LAMBDAS
+ [&q,&go]()
+ {
+ go.wait();
+ q.push(42);
+ }
+#else
+ call_push(q,go)
+#endif
+ );
+ pull_done=boost::async(boost::launch::async,
+#if ! defined BOOST_NO_CXX11_LAMBDAS
+ [&q,&go]() -> int
+ {
+ go.wait();
+ return q.pull();
+ }
+#else
+ call_pull(q,go)
+#endif
+ );
+
+ push_done.get();
+ BOOST_TEST_EQ(pull_done.get(), 42);
+ BOOST_TEST(q.empty());
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+void test_concurrent_push_on_empty_queue()
+{
+ boost::sync_queue<int> q;
+ const unsigned int n = 3;
+ boost::barrier go(n);
+ boost::future<void> push_done[n];
+
+ try
+ {
+ for (unsigned int i =0; i< n; ++i)
+ push_done[i]=boost::async(boost::launch::async,
+#if ! defined BOOST_NO_CXX11_LAMBDAS
+ [&q,&go]()
+ {
+ go.wait();
+ q.push(42);
+ }
+#else
+ call_push(q,go)
+#endif
+ );
+
+ for (unsigned int i = 0; i < n; ++i)
+ push_done[i].get();
+
+ BOOST_TEST(!q.empty());
+ for (unsigned int i =0; i< n; ++i)
+ BOOST_TEST_EQ(q.pull(), 42);
+ BOOST_TEST(q.empty());
+
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+void test_concurrent_pull_on_queue()
+{
+ boost::sync_queue<int> q;
+ const unsigned int n = 3;
+ boost::barrier go(n);
+
+ boost::future<int> pull_done[n];
+
+ try
+ {
+ for (unsigned int i =0; i< n; ++i)
+ q.push(42);
+
+ for (unsigned int i =0; i< n; ++i)
+ pull_done[i]=boost::async(boost::launch::async,
+#if ! defined BOOST_NO_CXX11_LAMBDAS
+ [&q,&go]() -> int
+ {
+ go.wait();
+ return q.pull();
+ }
+#else
+ call_pull(q,go)
+#endif
+ );
+
+ for (unsigned int i = 0; i < n; ++i)
+ BOOST_TEST_EQ(pull_done[i].get(), 42);
+ BOOST_TEST(q.empty());
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+int main()
+{
+ test_concurrent_push_and_pull_on_empty_queue();
+ test_concurrent_push_on_empty_queue();
+ test_concurrent_pull_on_queue();
+
+ return boost::report_errors();
+}
+

Copied: branches/release/libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp (from r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200, copy of r85193, trunk/libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp)
@@ -0,0 +1,203 @@
+// Copyright (C) 2013 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/sync_queue.hpp>
+
+// class sync_queue<T>
+
+// sync_queue();
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/sync_queue.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ // default queue invariants
+ boost::sync_queue<int> q;
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_pull fails
+ boost::sync_queue<int> q;
+ int i;
+ BOOST_TEST(! q.try_pull(i));
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_pull fails
+ boost::sync_queue<int> q;
+ BOOST_TEST(! q.try_pull());
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push rvalue succeeds
+ boost::sync_queue<int> q;
+ q.push(1);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push rvalue succeeds
+ boost::sync_queue<int> q;
+ q.push(1);
+ q.push(2);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 2u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push value succeeds
+ boost::sync_queue<int> q;
+ int i;
+ q.push(i);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push rvalue succeeds
+ boost::sync_queue<int> q;
+ BOOST_TEST(q.try_push(1));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push value succeeds
+ boost::sync_queue<int> q;
+ int i;
+ BOOST_TEST(q.try_push(i));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push rvalue succeeds
+ boost::sync_queue<int> q;
+ BOOST_TEST(q.try_push(boost::no_block, 1));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue pull succeed
+ boost::sync_queue<int> q;
+ q.push(1);
+ int i;
+ q.pull(i);
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue pull succeed
+ boost::sync_queue<int> q;
+ q.push(1);
+ int i = q.pull();
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue try_pull succeed
+ boost::sync_queue<int> q;
+ q.push(1);
+ int i;
+ BOOST_TEST(q.try_pull(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue try_pull succeed
+ boost::sync_queue<int> q;
+ q.push(1);
+ int i;
+ BOOST_TEST(q.try_pull(boost::no_block, i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue try_pull succeed
+ boost::sync_queue<int> q;
+ q.push(1);
+ boost::shared_ptr<int> i = q.try_pull();
+ BOOST_TEST_EQ(*i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+
+ {
+ // closed invariants
+ boost::sync_queue<int> q;
+ q.close();
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // closed queue push fails
+ boost::sync_queue<int> q;
+ q.close();
+ try {
+ q.push(1);
+ BOOST_TEST(false);
+ } catch (...) {
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ }
+ {
+ // 1-element closed queue pull succeed
+ boost::sync_queue<int> q;
+ q.push(1);
+ q.close();
+ int i;
+ q.pull(i);
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+
+ return boost::report_errors();
+}
+

Modified: branches/release/libs/thread/test/test_7160.cpp
==============================================================================
--- branches/release/libs/thread/test/test_7160.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/test/test_7160.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -10,28 +10,27 @@
 
 class ThreadClass
 {
- public:
+public:
   ThreadClass()
- {
- }
+ {
+ }
 
- void operator()()
- {
- return;
- }
+ void operator()()
+ {
+ return;
+ }
 };
 
-
 int main()
 {
- boost::posix_time::ptime currentTimeUTC;
+ boost::posix_time::ptime currentTimeUTC;
 
- ThreadClass tc;
- boost::thread t(tc);
- t.join(); //causes a runtime access violation here
+ ThreadClass tc;
+ boost::thread t(tc);
+ t.join(); //causes a runtime access violation here
 
- std::cout << "done" << std::endl;
- //system("pause");
+ std::cout << "done" << std::endl;
+ //system("pause");
 
- return 0;
+ return 0;
 }

Modified: branches/release/libs/thread/test/test_8596.cpp
==============================================================================
--- branches/release/libs/thread/test/test_8596.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/test/test_8596.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -6,6 +6,8 @@
 #define BOOST_THREAD_VERSION 4
 
 #include <iostream>
+#include <functional>
+#include <future>
 
 #include <boost/thread.hpp>
 #include <boost/shared_ptr.hpp>
@@ -28,6 +30,11 @@
 
 struct MyFunc
 {
+ MyFunc(MyFunc const&) = delete;
+ MyFunc& operator=(MyFunc const&) = delete;
+ MyFunc() {};
+ MyFunc(MyFunc &&) {};
+ MyFunc& operator=(MyFunc &&) { return *this;};
   void operator()()const {}
 };
 
@@ -41,12 +48,14 @@
   std::cout << "The answer to the ultimate question: " << fut.get() << std::endl;
 
   {
- //boost::function<void()> f;
+ boost::function<void()> f;
     MyFunc mf;
 
- //boost::packaged_task<void()> t1(f); // error 1
- boost::packaged_task<void()> t2(mf); // error 2
+ boost::packaged_task<void()> t1(f);
+ boost::packaged_task<void()> t2(boost::move(mf));
   }
 
   return 0;
 }
+
+

Copied: branches/release/libs/thread/test/test_8674.cpp (from r84708, trunk/libs/thread/test/test_8674.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/thread/test/test_8674.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200, copy of r84708, trunk/libs/thread/test/test_8674.cpp)
@@ -0,0 +1,43 @@
+// Copyright (C) 2013 Vicente Botet
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+
+#define USE_STD 0
+#define USE_BOOST 1
+
+#define USED_THREAD_API USE_BOOST
+//#define USED_THREAD_API USE_STD
+
+#if USED_THREAD_API == USE_BOOST
+
+# define BOOST_THREAD_VERSION 4
+# include <boost/thread/future.hpp>
+
+ using boost::future;
+ using boost::async;
+
+#endif
+#if USED_THREAD_API == USE_STD
+# include <future>
+ using std::future;
+ using std::async;
+#endif
+
+
+
+future<void> do_something()
+{
+ auto result = async( []{ std::cout<< "A\n"; } );
+ std::cout << "B\n";
+ return result; // error here
+}
+
+int main()
+{
+ do_something().wait();
+ std::cout << "Hello, World!" << std::endl;
+ return 0;
+}

Modified: branches/release/libs/thread/test/test_barrier.cpp
==============================================================================
--- branches/release/libs/thread/test/test_barrier.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/test/test_barrier.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -18,7 +18,7 @@
 namespace {
 
 // Shared variables for generation barrier test
-const int N_THREADS=10;
+const int N_THREADS=3;
 boost::barrier gen_barrier(N_THREADS);
 boost::mutex mutex;
 long global_parameter;

Copied and modified: branches/release/libs/thread/test/test_barrier_size_fct.cpp (from r84832, trunk/libs/thread/test/test_barrier_size_fct.cpp)
==============================================================================
--- trunk/libs/thread/test/test_barrier_size_fct.cpp Tue Jun 18 23:53:26 2013 (r84832, copy source)
+++ branches/release/libs/thread/test/test_barrier_size_fct.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -20,7 +20,7 @@
 long global_parameter;
 const int N_THREADS=3;
 
-std::size_t size_fct() {
+unsigned int size_fct() {
   global_parameter++;
   return N_THREADS;
 }

Copied: branches/release/libs/thread/test/test_barrier_void_fct.cpp (from r84832, trunk/libs/thread/test/test_barrier_void_fct.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/thread/test/test_barrier_void_fct.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200, copy of r84832, trunk/libs/thread/test/test_barrier_void_fct.cpp)
@@ -0,0 +1,67 @@
+// (C) Copyright 2013 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_THREAD_PROVIDES_INTERRUPTIONS
+
+#include <boost/thread/detail/config.hpp>
+
+#include <boost/thread/thread.hpp>
+#include <boost/thread/barrier.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+
+namespace {
+
+
+// Shared variables for generation barrier test
+long global_parameter;
+
+void void_fct() {
+ global_parameter++;
+}
+
+const int N_THREADS=3;
+boost::barrier gen_barrier(N_THREADS, void_fct);
+
+void barrier_thread()
+{
+ for (int i = 0; i < 5; ++i)
+ {
+ gen_barrier.count_down_and_wait();
+ }
+}
+
+} // namespace
+
+void test_barrier()
+{
+ boost::thread_group g;
+ global_parameter = 0;
+
+ try
+ {
+ for (int i = 0; i < N_THREADS; ++i)
+ g.create_thread(&barrier_thread);
+ g.join_all();
+ }
+ catch(...)
+ {
+ g.interrupt_all();
+ g.join_all();
+ throw;
+ }
+
+ BOOST_TEST(global_parameter==5);
+
+}
+
+int main()
+{
+
+ test_barrier();
+ return boost::report_errors();
+}
+

Modified: branches/release/libs/thread/test/threads/this_thread/sleep_for/sleep_for_pass.cpp
==============================================================================
--- branches/release/libs/thread/test/threads/this_thread/sleep_for/sleep_for_pass.cpp Sat Aug 3 09:05:31 2013 (r85199)
+++ branches/release/libs/thread/test/threads/this_thread/sleep_for/sleep_for_pass.cpp 2013-08-03 12:04:39 EDT (Sat, 03 Aug 2013) (r85200)
@@ -27,7 +27,6 @@
 {
   typedef boost::chrono::system_clock Clock;
   typedef Clock::time_point time_point;
- typedef Clock::duration duration;
   boost::chrono::milliseconds ms(500);
   time_point t0 = Clock::now();
   boost::this_thread::sleep_for(ms);


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