Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77443 - in trunk: boost/thread libs/thread/test libs/thread/test/sync/futures/future libs/thread/test/sync/futures/promise
From: vicente.botet_at_[hidden]
Date: 2012-03-20 19:49:33


Author: viboes
Date: 2012-03-20 19:49:31 EDT (Tue, 20 Mar 2012)
New Revision: 77443
URL: http://svn.boost.org/trac/boost/changeset/77443

Log:
Thread: Fixed error on promise v2 + added tests (share)
Added:
   trunk/libs/thread/test/sync/futures/future/share_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/futures/promise/copy_assign_fail.cpp
      - copied, changed from r77406, /trunk/libs/thread/test/sync/futures/promise/copy_asign_fail.cpp
   trunk/libs/thread/test/sync/futures/promise/move_assign_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/futures/promise/move_ctor_pass.cpp (contents, props changed)
Removed:
   trunk/libs/thread/test/sync/futures/promise/copy_asign_fail.cpp
Text files modified:
   trunk/boost/thread/future.hpp | 153 +++++++++++++++++++++++----------------
   trunk/libs/thread/test/Jamfile.v2 | 6 +
   trunk/libs/thread/test/sync/futures/promise/copy_assign_fail.cpp | 86 ++++++++++++++++++---
   trunk/libs/thread/test/sync/futures/promise/default_pass.cpp | 5 +
   trunk/libs/thread/test/sync/futures/promise/dtor_pass.cpp | 6 +
   5 files changed, 178 insertions(+), 78 deletions(-)

Modified: trunk/boost/thread/future.hpp
==============================================================================
--- trunk/boost/thread/future.hpp (original)
+++ trunk/boost/thread/future.hpp 2012-03-20 19:49:31 EDT (Tue, 20 Mar 2012)
@@ -789,8 +789,8 @@
 
 #ifndef BOOST_NO_DELETED_FUNCTIONS
     public:
- BOOST_THREAD_FUTURE(BOOST_THREAD_FUTURE & rhs) = delete;
- BOOST_THREAD_FUTURE& operator=(BOOST_THREAD_FUTURE& rhs) = delete;
+ BOOST_THREAD_FUTURE(BOOST_THREAD_FUTURE const& rhs) = delete;
+ BOOST_THREAD_FUTURE& operator=(BOOST_THREAD_FUTURE const& rhs) = delete;
 #else // BOOST_NO_DELETED_FUNCTIONS
     private:
       BOOST_THREAD_FUTURE(BOOST_THREAD_FUTURE & rhs);// = delete;
@@ -824,11 +824,11 @@
         {}
 
 #ifndef BOOST_NO_RVALUE_REFERENCES
- BOOST_THREAD_FUTURE(BOOST_THREAD_FUTURE && other)
+ BOOST_THREAD_FUTURE(BOOST_THREAD_FUTURE && other) BOOST_NOEXCEPT
         {
             future_.swap(other.future_);
         }
- BOOST_THREAD_FUTURE& operator=(BOOST_THREAD_FUTURE && other)
+ BOOST_THREAD_FUTURE& operator=(BOOST_THREAD_FUTURE && other) BOOST_NOEXCEPT
         {
             future_=other.future_;
             other.future_.reset();
@@ -836,13 +836,13 @@
         }
 #else
 #if defined BOOST_THREAD_USES_MOVE
- BOOST_THREAD_FUTURE(boost::rv<BOOST_THREAD_FUTURE>& other):
+ BOOST_THREAD_FUTURE(boost::rv<BOOST_THREAD_FUTURE>& other) BOOST_NOEXCEPT:
             future_(other.future_)
         {
             other.future_.reset();
         }
 
- BOOST_THREAD_FUTURE& operator=(boost::rv<BOOST_THREAD_FUTURE>& other)
+ BOOST_THREAD_FUTURE& operator=(boost::rv<BOOST_THREAD_FUTURE>& other) BOOST_NOEXCEPT
         {
             future_=other.future_;
             other.future_.reset();
@@ -865,13 +865,13 @@
           return *static_cast<const ::boost::rv<BOOST_THREAD_FUTURE>* >(this);
         }
 #else
- BOOST_THREAD_FUTURE(boost::detail::thread_move_t<BOOST_THREAD_FUTURE> other):
+ BOOST_THREAD_FUTURE(boost::detail::thread_move_t<BOOST_THREAD_FUTURE> other) BOOST_NOEXCEPT:
             future_(other->future_)
         {
             other->future_.reset();
         }
 
- BOOST_THREAD_FUTURE& operator=(boost::detail::thread_move_t<BOOST_THREAD_FUTURE> other)
+ BOOST_THREAD_FUTURE& operator=(boost::detail::thread_move_t<BOOST_THREAD_FUTURE> other) BOOST_NOEXCEPT
         {
             future_=other->future_;
             other->future_.reset();
@@ -888,6 +888,10 @@
         }
 #endif
 #endif
+ shared_future<R> share()
+ {
+ return shared_future<R>(::boost::move(*this));
+ }
 
         void swap(BOOST_THREAD_FUTURE& other)
         {
@@ -906,7 +910,7 @@
         }
 
         // functions to check state, and wait for ready
- state get_state() const
+ state get_state() const BOOST_NOEXCEPT
         {
             if(!future_)
             {
@@ -916,22 +920,22 @@
         }
 
 
- bool is_ready() const
+ bool is_ready() const BOOST_NOEXCEPT
         {
             return get_state()==future_state::ready;
         }
 
- bool has_exception() const
+ bool has_exception() const BOOST_NOEXCEPT
         {
             return future_ && future_->has_exception();
         }
 
- bool has_value() const
+ bool has_value() const BOOST_NOEXCEPT
         {
             return future_ && future_->has_value();
         }
 
- bool valid() const
+ bool valid() const BOOST_NOEXCEPT
         {
             return future_ != 0;
         }
@@ -1025,21 +1029,21 @@
             return *this;
         }
 #ifndef BOOST_NO_RVALUE_REFERENCES
- shared_future(shared_future && other)
+ shared_future(shared_future && other) BOOST_NOEXCEPT
         {
             future_.swap(other.future_);
         }
- shared_future(BOOST_THREAD_FUTURE<R> && other)
+ shared_future(BOOST_THREAD_FUTURE<R> && other) BOOST_NOEXCEPT
         {
             future_.swap(other.future_);
         }
- shared_future& operator=(shared_future && other)
+ shared_future& operator=(shared_future && other) BOOST_NOEXCEPT
         {
             future_.swap(other.future_);
             other.future_.reset();
             return *this;
         }
- shared_future& operator=(BOOST_THREAD_FUTURE<R> && other)
+ shared_future& operator=(BOOST_THREAD_FUTURE<R> && other) BOOST_NOEXCEPT
         {
             future_.swap(other.future_);
             other.future_.reset();
@@ -1047,24 +1051,24 @@
         }
 #else
 #if defined BOOST_THREAD_USES_MOVE
- shared_future(boost::rv<shared_future>& other):
+ shared_future(boost::rv<shared_future>& other) BOOST_NOEXCEPT :
             future_(other.future_)
         {
             other.future_.reset();
         }
 // shared_future(const BOOST_THREAD_FUTURE<R> &) = delete;
- shared_future(boost::rv<BOOST_THREAD_FUTURE<R> >& other):
+ shared_future(boost::rv<BOOST_THREAD_FUTURE<R> >& other) BOOST_NOEXCEPT :
             future_(other.future_)
         {
             other.future_.reset();
         }
- shared_future& operator=(boost::rv<shared_future>& other)
+ shared_future& operator=(boost::rv<shared_future>& other) BOOST_NOEXCEPT
         {
             future_.swap(other.future_);
             other.future_.reset();
             return *this;
         }
- shared_future& operator=(boost::rv<BOOST_THREAD_FUTURE<R> >& other)
+ shared_future& operator=(boost::rv<BOOST_THREAD_FUTURE<R> >& other) BOOST_NOEXCEPT
         {
             future_.swap(other.future_);
             other.future_.reset();
@@ -1089,24 +1093,24 @@
 
 #else
 
- shared_future(boost::detail::thread_move_t<shared_future> other):
+ shared_future(boost::detail::thread_move_t<shared_future> other) BOOST_NOEXCEPT :
             future_(other->future_)
         {
             other->future_.reset();
         }
 // shared_future(const BOOST_THREAD_FUTURE<R> &) = delete;
- shared_future(boost::detail::thread_move_t<BOOST_THREAD_FUTURE<R> > other):
+ shared_future(boost::detail::thread_move_t<BOOST_THREAD_FUTURE<R> > other) BOOST_NOEXCEPT :
             future_(other->future_)
         {
             other->future_.reset();
         }
- shared_future& operator=(boost::detail::thread_move_t<shared_future> other)
+ shared_future& operator=(boost::detail::thread_move_t<shared_future> other) BOOST_NOEXCEPT
         {
             future_.swap(other->future_);
             other->future_.reset();
             return *this;
         }
- shared_future& operator=(boost::detail::thread_move_t<BOOST_THREAD_FUTURE<R> > other)
+ shared_future& operator=(boost::detail::thread_move_t<BOOST_THREAD_FUTURE<R> > other) BOOST_NOEXCEPT
         {
             future_.swap(other->future_);
             other->future_.reset();
@@ -1124,7 +1128,7 @@
 #endif
 #endif
 
- void swap(shared_future& other)
+ void swap(shared_future& other) BOOST_NOEXCEPT
         {
             future_.swap(other.future_);
         }
@@ -1141,7 +1145,7 @@
         }
 
         // functions to check state, and wait for ready
- state get_state() const
+ state get_state() const BOOST_NOEXCEPT
         {
             if(!future_)
             {
@@ -1150,18 +1154,22 @@
             return future_->get_state();
         }
 
+ bool valid() const BOOST_NOEXCEPT
+ {
+ return future_ != 0;
+ }
 
- bool is_ready() const
+ bool is_ready() const BOOST_NOEXCEPT
         {
             return get_state()==future_state::ready;
         }
 
- bool has_exception() const
+ bool has_exception() const BOOST_NOEXCEPT
         {
             return future_ && future_->has_exception();
         }
 
- bool has_value() const
+ bool has_value() const BOOST_NOEXCEPT
         {
             return future_ && future_->has_value();
         }
@@ -1228,8 +1236,8 @@
 
 #ifndef BOOST_NO_DELETED_FUNCTIONS
     public:
- promise(promise const& rhs);// = delete;
- promise & operator=(promise const & rhs);// = delete;
+ promise(promise const& rhs) = delete;
+ promise & operator=(promise const & rhs) = delete;
 #else // BOOST_NO_DELETED_FUNCTIONS
     private:
         promise(promise & rhs);// = delete;
@@ -1275,21 +1283,21 @@
 
         // Assignment
 #ifndef BOOST_NO_RVALUE_REFERENCES
- promise(promise && rhs):
-#if ! BOOST_THREAD_VERSION==1
- future_(rhs.future_),
-#endif
+ promise(promise && rhs) BOOST_NOEXCEPT:
+//#if ! BOOST_THREAD_VERSION==1
+ // future_(rhs.future_),
+//#endif
             future_obtained(rhs.future_obtained)
         {
-#if BOOST_THREAD_VERSION==1
- future_.swap(rhs.future_);
-#else
- // we need to release the future as shared_ptr doesn't implements move semantics
+//#if BOOST_THREAD_VERSION==1
+ future_.swap(rhs.future_);
+//#else
+ // we need to release the future as shared_ptr doesn't implements move semantics
             rhs.future_.reset();
-#endif
+//#endif
             rhs.future_obtained=false;
         }
- promise & operator=(promise&& rhs)
+ promise & operator=(promise&& rhs) BOOST_NOEXCEPT
         {
 #if BOOST_THREAD_VERSION==1
             future_.swap(rhs.future_);
@@ -1304,13 +1312,13 @@
         }
 #else
 #if defined BOOST_THREAD_USES_MOVE
- promise(boost::rv<promise>& rhs):
+ promise(boost::rv<promise>& rhs) BOOST_NOEXCEPT :
             future_(rhs.future_),future_obtained(rhs.future_obtained)
         {
             rhs.future_.reset();
             rhs.future_obtained=false;
         }
- promise & operator=(boost::rv<promise>& rhs)
+ promise & operator=(boost::rv<promise>& rhs) BOOST_NOEXCEPT
         {
             future_=rhs.future_;
             future_obtained=rhs.future_obtained;
@@ -1335,13 +1343,13 @@
           return *static_cast<const ::boost::rv<promise>* >(this);
         }
 #else
- promise(boost::detail::thread_move_t<promise> rhs):
+ promise(boost::detail::thread_move_t<promise> rhs) BOOST_NOEXCEPT:
             future_(rhs->future_),future_obtained(rhs->future_obtained)
         {
             rhs->future_.reset();
             rhs->future_obtained=false;
         }
- promise & operator=(boost::detail::thread_move_t<promise> rhs)
+ promise & operator=(boost::detail::thread_move_t<promise> rhs) BOOST_NOEXCEPT
         {
             future_=rhs->future_;
             future_obtained=rhs->future_obtained;
@@ -1432,8 +1440,8 @@
 
 #ifndef BOOST_NO_DELETED_FUNCTIONS
     public:
- promise(promise const& rhs);// = delete;
- promise & operator=(promise const & rhs);// = delete;
+ promise(promise const& rhs) = delete;
+ promise & operator=(promise const & rhs) = delete;
 #else // BOOST_NO_DELETED_FUNCTIONS
     private:
         promise(promise & rhs);// = delete;
@@ -1443,17 +1451,24 @@
 
         void lazy_init()
         {
+#if BOOST_THREAD_VERSION==1
             if(!atomic_load(&future_))
             {
                 future_ptr blank;
                 atomic_compare_exchange(&future_,&blank,future_ptr(new detail::future_object<void>));
             }
+#endif
         }
     public:
 // template <class Allocator> explicit promise(Allocator a);
 
         promise():
- future_(),future_obtained(false)
+#if BOOST_THREAD_VERSION==1
+ future_(),
+#else
+ future_(new detail::future_object<void>),
+#endif
+ future_obtained(false)
         {}
 
         ~promise()
@@ -1471,13 +1486,15 @@
 
         // Assignment
 #ifndef BOOST_NO_RVALUE_REFERENCES
- promise(promise && rhs):
+ promise(promise && rhs) BOOST_NOEXCEPT :
             future_obtained(rhs.future_obtained)
         {
             future_.swap(rhs.future_);
+ // we need to release the future as shared_ptr doesn't implements move semantics
+ rhs.future_.reset();
             rhs.future_obtained=false;
         }
- promise & operator=(promise&& rhs)
+ promise & operator=(promise&& rhs) BOOST_NOEXCEPT
         {
             future_.swap(rhs.future_);
             future_obtained=rhs.future_obtained;
@@ -1487,13 +1504,13 @@
         }
 #else
 #if defined BOOST_THREAD_USES_MOVE
- promise(boost::rv<promise>& rhs):
+ promise(boost::rv<promise>& rhs) BOOST_NOEXCEPT :
             future_(rhs.future_),future_obtained(rhs.future_obtained)
         {
             rhs.future_.reset();
             rhs.future_obtained=false;
         }
- promise & operator=(boost::rv<promise>& rhs)
+ promise & operator=(boost::rv<promise>& rhs) BOOST_NOEXCEPT
         {
             future_=rhs.future_;
             future_obtained=rhs.future_obtained;
@@ -1518,13 +1535,13 @@
           return *static_cast<const ::boost::rv<promise>* >(this);
         }
 #else
- promise(boost::detail::thread_move_t<promise> rhs):
+ promise(boost::detail::thread_move_t<promise> rhs) BOOST_NOEXCEPT :
             future_(rhs->future_),future_obtained(rhs->future_obtained)
         {
             rhs->future_.reset();
             rhs->future_obtained=false;
         }
- promise & operator=(boost::detail::thread_move_t<promise> rhs)
+ promise & operator=(boost::detail::thread_move_t<promise> rhs) BOOST_NOEXCEPT
         {
             future_=rhs->future_;
             future_obtained=rhs->future_obtained;
@@ -1555,6 +1572,10 @@
         {
             lazy_init();
 
+ if (future_.get()==0)
+ {
+ boost::throw_exception(promise_moved());
+ }
             if(future_obtained)
             {
                 boost::throw_exception(future_already_retrieved());
@@ -1735,8 +1756,8 @@
 
 #ifndef BOOST_NO_DELETED_FUNCTIONS
     public:
- packaged_task(packaged_task const&);// = delete;
- packaged_task& operator=(packaged_task const&);// = delete;
+ packaged_task(packaged_task const&) = delete;
+ packaged_task& operator=(packaged_task const&) = delete;
 #else // BOOST_NO_DELETED_FUNCTIONS
     private:
         packaged_task(packaged_task&);// = delete;
@@ -1791,13 +1812,13 @@
 
         // assignment
 #ifndef BOOST_NO_RVALUE_REFERENCES
- packaged_task(packaged_task&& other):
+ packaged_task(packaged_task&& other) BOOST_NOEXCEPT :
             future_obtained(other.future_obtained)
         {
             task.swap(other.task);
             other.future_obtained=false;
         }
- packaged_task& operator=(packaged_task&& other)
+ packaged_task& operator=(packaged_task&& other) BOOST_NOEXCEPT
         {
             packaged_task temp(static_cast<packaged_task&&>(other));
             swap(temp);
@@ -1805,13 +1826,13 @@
         }
 #else
 #if defined BOOST_THREAD_USES_MOVE
- packaged_task(boost::rv<packaged_task>& other):
+ packaged_task(boost::rv<packaged_task>& other) BOOST_NOEXCEPT :
             future_obtained(other.future_obtained)
         {
             task.swap(other.task);
             other.future_obtained=false;
         }
- packaged_task& operator=(boost::rv<packaged_task>& other)
+ packaged_task& operator=(boost::rv<packaged_task>& other) BOOST_NOEXCEPT
         {
             packaged_task temp(other);
             swap(temp);
@@ -1834,13 +1855,13 @@
           return *static_cast<const ::boost::rv<packaged_task>* >(this);
         }
 #else
- packaged_task(boost::detail::thread_move_t<packaged_task> other):
+ packaged_task(boost::detail::thread_move_t<packaged_task> other) BOOST_NOEXCEPT:
             future_obtained(other->future_obtained)
         {
             task.swap(other->task);
             other->future_obtained=false;
         }
- packaged_task& operator=(boost::detail::thread_move_t<packaged_task> other)
+ packaged_task& operator=(boost::detail::thread_move_t<packaged_task> other) BOOST_NOEXCEPT
         {
             packaged_task temp(other);
             swap(temp);
@@ -1857,11 +1878,15 @@
 #endif
 #endif
 
- void swap(packaged_task& other)
+ void swap(packaged_task& other) BOOST_NOEXCEPT
         {
             task.swap(other.task);
             std::swap(future_obtained,other.future_obtained);
         }
+ bool valid() const BOOST_NOEXCEPT
+ {
+ return task.get()!=0;
+ }
 
         // result retrieval
         BOOST_THREAD_FUTURE<R> get_future()

Modified: trunk/libs/thread/test/Jamfile.v2
==============================================================================
--- trunk/libs/thread/test/Jamfile.v2 (original)
+++ trunk/libs/thread/test/Jamfile.v2 2012-03-20 19:49:31 EDT (Tue, 20 Mar 2012)
@@ -147,9 +147,15 @@
     test-suite futures
     :
     # [ thread-run2 ./sync/futures/async/async_pass.cpp : async__async_p ]
+ [ thread-compile-fail-V2 ./sync/futures/promise/copy_assign_fail.cpp : : promise__copy_assign_f ]
           [ thread-run2 ./sync/futures/promise/default_pass.cpp : promise__default_p ]
           [ thread-run2 ./sync/futures/promise/dtor_pass.cpp : promise__dtor_p ]
           [ thread-run2 ./sync/futures/promise/get_future_pass.cpp : promise__get_future_p ]
+ [ thread-run2 ./sync/futures/promise/move_ctor_pass.cpp : promise__move_ctor_p ]
+ [ thread-run2 ./sync/futures/promise/move_assign_pass.cpp : promise__move_asign_p ]
+
+ [ thread-run2 ./sync/futures/future/share_pass.cpp : future__share_p ]
+
     ;
 
 

Added: trunk/libs/thread/test/sync/futures/future/share_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/futures/future/share_pass.cpp 2012-03-20 19:49:31 EDT (Tue, 20 Mar 2012)
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 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>
+
+// shared_future<R> share() &&;
+
+#define BOOST_THREAD_VERSION 2
+
+#include <boost/thread/future.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ typedef int T;
+ boost::promise<T> p;
+ boost::future<T> f0 = p.get_future();
+ boost::shared_future<T> sf = f0.share();
+ boost::shared_future<T> f = sf;
+ BOOST_TEST(!f0.valid());
+ BOOST_TEST(f.valid());
+ }
+ {
+ typedef int T;
+ boost::future<T> f0;
+ boost::shared_future<T> sf = f0.share();
+ boost::shared_future<T> f = sf;
+ BOOST_TEST(!f0.valid());
+ BOOST_TEST(!f.valid());
+ }
+ {
+ typedef int& T;
+ boost::promise<T> p;
+ boost::future<T> f0 = p.get_future();
+ boost::shared_future<T> sf = f0.share();
+ boost::shared_future<T> f = sf;
+ BOOST_TEST(!f0.valid());
+ BOOST_TEST(f.valid());
+ }
+ {
+ typedef int& T;
+ boost::future<T> f0;
+ boost::shared_future<T> sf = f0.share();
+ boost::shared_future<T> f = sf;
+ BOOST_TEST(!f0.valid());
+ BOOST_TEST(!f.valid());
+ }
+ {
+ typedef void T;
+ boost::promise<T> p;
+ boost::future<T> f0 = p.get_future();
+ boost::shared_future<T> sf = f0.share();
+ boost::shared_future<T> f = sf;
+ BOOST_TEST(!f0.valid());
+ BOOST_TEST(f.valid());
+ }
+ {
+ typedef void T;
+ boost::future<T> f0;
+ boost::shared_future<T> sf = f0.share();
+ boost::shared_future<T> f = sf;
+ BOOST_TEST(!f0.valid());
+ BOOST_TEST(!f.valid());
+ }
+
+
+ return boost::report_errors();
+}
+

Deleted: trunk/libs/thread/test/sync/futures/promise/copy_asign_fail.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/promise/copy_asign_fail.cpp 2012-03-20 19:49:31 EDT (Tue, 20 Mar 2012)
+++ (empty file)
@@ -1,42 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// Copyright (C) 2011 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>
-
-#include <boost/thread/future.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-
-int main()
-{
-
- {
- boost::promise<int> p;
- boost::future<int> f = p.get_future();
- BOOST_TEST(f.valid());
- }
- {
- boost::promise<int&> p;
- boost::future<int&> f = p.get_future();
- BOOST_TEST(f.valid());
- }
- {
- boost::promise<void> p;
- boost::future<void> f = p.get_future();
- BOOST_TEST(f.valid());
- }
-
- return boost::report_errors();
-}
-

Copied: trunk/libs/thread/test/sync/futures/promise/copy_assign_fail.cpp (from r77406, /trunk/libs/thread/test/sync/futures/promise/copy_asign_fail.cpp)
==============================================================================
--- /trunk/libs/thread/test/sync/futures/promise/copy_asign_fail.cpp (original)
+++ trunk/libs/thread/test/sync/futures/promise/copy_assign_fail.cpp 2012-03-20 19:49:31 EDT (Tue, 20 Mar 2012)
@@ -13,29 +13,87 @@
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 // <boost/thread/future.hpp>
+// class promise<R>
+// promise& operator=(const promise& rhs) = delete;
 
+#define BOOST_THREAD_VERSION 2
 #include <boost/thread/future.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
-
 int main()
 {
 
+ //BOOST_TEST(test_alloc_base::count == 0);
   {
- boost::promise<int> p;
- boost::future<int> f = p.get_future();
- BOOST_TEST(f.valid());
- }
- {
- boost::promise<int&> p;
- boost::future<int&> f = p.get_future();
- BOOST_TEST(f.valid());
- }
- {
- boost::promise<void> p;
- boost::future<void> f = p.get_future();
- BOOST_TEST(f.valid());
+ //boost::promise<int> p0(boost::allocator_arg, test_allocator<int>());
+ //boost::promise<int> p(boost::allocator_arg, test_allocator<int>());
+ boost::promise<int> p0;
+ boost::promise<int> p;
+ //BOOST_TEST(test_alloc_base::count == 2);
+ p = p0;
+ //BOOST_TEST(test_alloc_base::count == 1);
+ boost::future<int> f = p.get_future();
+ //BOOST_TEST(test_alloc_base::count == 1);
+ BOOST_TEST(f.valid());
+ try
+ {
+ f = p0.get_future();
+ BOOST_TEST(false);
+ }
+ catch (const boost::future_error& e)
+ {
+ BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
+ }
+ //BOOST_TEST(test_alloc_base::count == 1);
   }
+ //BOOST_TEST(test_alloc_base::count == 0);
+// {
+// //boost::promise<int&> p0(boost::allocator_arg, test_allocator<int>());
+// //boost::promise<int&> p(boost::allocator_arg, test_allocator<int>());
+// boost::promise<int&> p0;
+// boost::promise<int&> p;
+// //BOOST_TEST(test_alloc_base::count == 2);
+// p = p0;
+// //BOOST_TEST(test_alloc_base::count == 1);
+// boost::future<int&> f = p.get_future();
+// //BOOST_TEST(test_alloc_base::count == 1);
+// BOOST_TEST(f.valid());
+// try
+// {
+// f = p0.get_future();
+// BOOST_TEST(false);
+// }
+// catch (const boost::future_error& e)
+// {
+// BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
+// }
+// //BOOST_TEST(test_alloc_base::count == 1);
+// }
+// //BOOST_TEST(test_alloc_base::count == 0);
+// {
+// //boost::promise<void> p0(boost::allocator_arg, test_allocator<void>());
+// //boost::promise<void> p(boost::allocator_arg, test_allocator<void>());
+// boost::promise<void> p0;
+// boost::promise<void> p;
+// //BOOST_TEST(test_alloc_base::count == 2);
+// p = p0;
+// //BOOST_TEST(test_alloc_base::count == 1);
+// boost::future<void> f = p.get_future();
+// //BOOST_TEST(test_alloc_base::count == 1);
+// BOOST_TEST(f.valid());
+// try
+// {
+// f = p0.get_future();
+// BOOST_TEST(false);
+// }
+// catch (const boost::future_error& e)
+// {
+// BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
+// }
+// //BOOST_TEST(test_alloc_base::count == 1);
+// }
+ //BOOST_TEST(test_alloc_base::count == 0);
+
 
   return boost::report_errors();
 }

Modified: trunk/libs/thread/test/sync/futures/promise/default_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/promise/default_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/promise/default_pass.cpp 2012-03-20 19:49:31 EDT (Tue, 20 Mar 2012)
@@ -25,20 +25,25 @@
 
 int main()
 {
+ std::cout << __LINE__ << std::endl;
 
   {
       boost::promise<int> p;
       boost::future<int> f = p.get_future();
       BOOST_TEST(f.valid());
   }
+ std::cout << __LINE__ << std::endl;
   {
       boost::promise<int&> p;
       boost::future<int&> f = p.get_future();
       BOOST_TEST(f.valid());
   }
+ std::cout << __LINE__ << std::endl;
   {
       boost::promise<void> p;
+ std::cout << __LINE__ << std::endl;
       boost::future<void> f = p.get_future();
+ std::cout << __LINE__ << std::endl;
       BOOST_TEST(f.valid());
   }
 

Modified: trunk/libs/thread/test/sync/futures/promise/dtor_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/promise/dtor_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/promise/dtor_pass.cpp 2012-03-20 19:49:31 EDT (Tue, 20 Mar 2012)
@@ -25,6 +25,7 @@
 
 int main()
 {
+ std::cout << __LINE__ << std::endl;
   {
       typedef int T;
       boost::future<T> f;
@@ -35,6 +36,7 @@
       }
       BOOST_TEST(f.get() == 3);
   }
+ std::cout << __LINE__ << std::endl;
   {
       typedef int T;
       boost::future<T> f;
@@ -53,6 +55,7 @@
       }
   }
 
+ std::cout << __LINE__ << std::endl;
   {
       typedef int& T;
       int i = 4;
@@ -64,6 +67,7 @@
       }
       BOOST_TEST(&f.get() == &i);
   }
+ std::cout << __LINE__ << std::endl;
   {
       typedef int& T;
       boost::future<T> f;
@@ -82,6 +86,7 @@
       }
   }
 
+ std::cout << __LINE__ << std::endl;
   {
       typedef void T;
       boost::future<T> f;
@@ -93,6 +98,7 @@
       f.get();
       BOOST_TEST(true);
   }
+ std::cout << __LINE__ << std::endl;
   {
       typedef void T;
       boost::future<T> f;

Added: trunk/libs/thread/test/sync/futures/promise/move_assign_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/futures/promise/move_assign_pass.cpp 2012-03-20 19:49:31 EDT (Tue, 20 Mar 2012)
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 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)
+
+// <future>
+
+// class promise<R>
+
+// promise& operator=(promise&& rhs);
+
+#define BOOST_THREAD_VERSION 2
+
+#include <boost/thread/future.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m0;
+boost::mutex m1;
+
+int main()
+{
+ //BOOST_TEST(test_alloc_base::count == 0);
+ {
+ //boost::promise<int> p0(boost::allocator_arg, test_allocator<int>());
+ //boost::promise<int> p(boost::allocator_arg, test_allocator<int>());
+ boost::promise<int> p0;
+ boost::promise<int> p;
+ //BOOST_TEST(test_alloc_base::count == 2);
+ p = boost::move(p0);
+ //BOOST_TEST(test_alloc_base::count == 1);
+ boost::future<int> f = p.get_future();
+ //BOOST_TEST(test_alloc_base::count == 1);
+ BOOST_TEST(f.valid());
+ try
+ {
+ f = p0.get_future();
+ BOOST_TEST(false);
+ }
+ catch (const boost::future_error& e)
+ {
+ BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
+ }
+ //BOOST_TEST(test_alloc_base::count == 1);
+ }
+ //BOOST_TEST(test_alloc_base::count == 0);
+ {
+ //boost::promise<int&> p0(boost::allocator_arg, test_allocator<int>());
+ //boost::promise<int&> p(boost::allocator_arg, test_allocator<int>());
+ boost::promise<int&> p0;
+ boost::promise<int&> p;
+ //BOOST_TEST(test_alloc_base::count == 2);
+ p = boost::move(p0);
+ //BOOST_TEST(test_alloc_base::count == 1);
+ boost::future<int&> f = p.get_future();
+ //BOOST_TEST(test_alloc_base::count == 1);
+ BOOST_TEST(f.valid());
+ try
+ {
+ f = p0.get_future();
+ BOOST_TEST(false);
+ }
+ catch (const boost::future_error& e)
+ {
+ BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
+ }
+ //BOOST_TEST(test_alloc_base::count == 1);
+ }
+ //BOOST_TEST(test_alloc_base::count == 0);
+ {
+ //boost::promise<void> p0(boost::allocator_arg, test_allocator<void>());
+ //boost::promise<void> p(boost::allocator_arg, test_allocator<void>());
+ boost::promise<void> p0;
+ boost::promise<void> p;
+ //BOOST_TEST(test_alloc_base::count == 2);
+ p = boost::move(p0);
+ //BOOST_TEST(test_alloc_base::count == 1);
+ boost::future<void> f = p.get_future();
+ //BOOST_TEST(test_alloc_base::count == 1);
+ BOOST_TEST(f.valid());
+ try
+ {
+ f = p0.get_future();
+ BOOST_TEST(false);
+ }
+ catch (const boost::future_error& e)
+ {
+ BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
+ }
+ //BOOST_TEST(test_alloc_base::count == 1);
+ }
+ //BOOST_TEST(test_alloc_base::count == 0);
+
+ return boost::report_errors();
+
+}
+

Added: trunk/libs/thread/test/sync/futures/promise/move_ctor_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/futures/promise/move_ctor_pass.cpp 2012-03-20 19:49:31 EDT (Tue, 20 Mar 2012)
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011 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)
+
+// <future>
+
+// class promise<R>
+
+// promise(promise&& rhs);
+
+#define BOOST_THREAD_VERSION 2
+
+#include <boost/thread/future.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m;
+
+int main()
+{
+ std::cout << __LINE__ << std::endl;
+ //BOOST_TEST(test_alloc_base::count == 0);
+ {
+ //boost::promise<int> p0(boost::allocator_arg, test_allocator<int>());
+ //boost::promise<int> p(boost::move(p0));
+ boost::promise<int> p0;
+ boost::promise<int> p(boost::move(p0));
+ //BOOST_TEST(test_alloc_base::count == 1);
+ std::cout << __LINE__ << std::endl;
+ boost::future<int> f = p.get_future();
+ std::cout << __LINE__ << std::endl;
+ //BOOST_TEST(test_alloc_base::count == 1);
+ BOOST_TEST(f.valid());
+ std::cout << __LINE__ << std::endl;
+ try
+ {
+ f = p0.get_future();
+ BOOST_TEST(false);
+ }
+ catch (const boost::future_error& e)
+ {
+ BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
+ }
+ std::cout << __LINE__ << std::endl;
+ //BOOST_TEST(test_alloc_base::count == 1);
+ }
+ std::cout << __LINE__ << std::endl;
+ //BOOST_TEST(test_alloc_base::count == 0);
+ {
+ //boost::promise<int&> p0(boost::allocator_arg, test_allocator<int>());
+ //boost::promise<int&> p(boost::move(p0));
+ boost::promise<int&> p0;
+ boost::promise<int&> p(boost::move(p0));
+ //BOOST_TEST(test_alloc_base::count == 1);
+ boost::future<int&> f = p.get_future();
+ //BOOST_TEST(test_alloc_base::count == 1);
+ BOOST_TEST(f.valid());
+ try
+ {
+ f = p0.get_future();
+ BOOST_TEST(false);
+ }
+ catch (const boost::future_error& e)
+ {
+ BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
+ }
+ //BOOST_TEST(test_alloc_base::count == 1);
+ }
+ //BOOST_TEST(test_alloc_base::count == 0);
+ {
+ //boost::promise<void> p0(boost::allocator_arg, test_allocator<void>());
+ //boost::promise<void> p(boost::move(p0));
+ boost::promise<void> p0;
+ boost::promise<void> p(boost::move(p0));
+ //BOOST_TEST(test_alloc_base::count == 1);
+ boost::future<void> f = p.get_future();
+ //BOOST_TEST(test_alloc_base::count == 1);
+ BOOST_TEST(f.valid());
+ try
+ {
+ f = p0.get_future();
+ BOOST_TEST(false);
+ }
+ catch (const boost::future_error& e)
+ {
+ BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
+ }
+ //BOOST_TEST(test_alloc_base::count == 1);
+ }
+ //BOOST_TEST(test_alloc_base::count == 0);
+
+
+ return boost::report_errors();
+}
+


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