Ticket #6228: 6228.patch
File 6228.patch, 53.6 KB (added by , 11 years ago) |
---|
-
future.hpp
36 36 #include <boost/chrono/system_clocks.hpp> 37 37 #endif 38 38 39 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS 40 #include <boost/thread/detail/memory.hpp> 41 #endif 42 39 43 #if BOOST_THREAD_VERSION==1 40 44 #define BOOST_THREAD_FUTURE unique_future 41 45 #else … … 556 560 future_object& operator=(future_object const&); 557 561 }; 558 562 563 template<typename T, typename Allocator> 564 struct future_object_alloc: public future_object<T> 565 { 566 typedef future_object<T> base; 567 Allocator alloc_; 568 569 public: 570 explicit future_object_alloc(const Allocator& a) 571 : alloc_(a) {} 572 573 }; 559 574 class future_waiter 560 575 { 561 576 struct registered_waiter; … … 1257 1272 } 1258 1273 1259 1274 public: 1260 // template <class Allocator> explicit promise(Allocator a); 1275 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS 1276 template <class Allocator> 1277 explicit promise(boost::container::allocator_arg_t, Allocator a) 1278 { 1279 typedef typename Allocator::template rebind<detail::future_object<R> >::other A2; 1280 A2 a2(a); 1281 typedef thread_detail::allocator_destructor<A2> D; 1261 1282 1283 future_ = future_ptr(::new(a2.allocate(1)) detail::future_object<R>(), D(a2, 1) ); 1284 future_obtained = false; 1285 } 1286 #endif 1262 1287 promise(): 1263 1288 #if BOOST_THREAD_VERSION==1 1264 1289 future_(), 1265 1290 #else 1266 future_(new detail::future_object<R> ),1291 future_(new detail::future_object<R>()), 1267 1292 #endif 1268 1293 future_obtained(false) 1269 1294 {} … … 1460 1485 #endif 1461 1486 } 1462 1487 public: 1463 // template <class Allocator> explicit promise(Allocator a); 1488 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS 1489 template <class Allocator> 1490 explicit promise(boost::container::allocator_arg_t, Allocator a) 1491 { 1492 typedef typename Allocator::template rebind<detail::future_object<void> >::other A2; 1493 A2 a2(a); 1494 typedef thread_detail::allocator_destructor<A2> D; 1464 1495 1496 future_ = future_ptr(::new(a2.allocate(1)) detail::future_object<void>(), D(a2, 1) ); 1497 future_obtained = false; 1498 } 1499 #endif 1465 1500 promise(): 1466 1501 #if BOOST_THREAD_VERSION==1 1467 1502 future_(), -
../../libs/thread/test/sync/futures/test_allocator.hpp
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 #ifndef BOOST_THREAD_TEST_ALLOCATOR_HPP 16 #define BOOST_THREAD_TEST_ALLOCATOR_HPP 17 18 #include <cstddef> 19 #include <boost/type_traits.hpp> 20 #include <boost/thread/detail/move.hpp> 21 #include <cstdlib> 22 #include <new> 23 #include <climits> 24 25 class test_alloc_base 26 { 27 public: 28 static int count; 29 public: 30 static int throw_after; 31 }; 32 33 int test_alloc_base::count = 0; 34 int test_alloc_base::throw_after = INT_MAX; 35 36 template <class T> 37 class test_allocator 38 : public test_alloc_base 39 { 40 int data_; 41 42 template <class U> friend class test_allocator; 43 public: 44 45 typedef unsigned size_type; 46 typedef int difference_type; 47 typedef T value_type; 48 typedef value_type* pointer; 49 typedef const value_type* const_pointer; 50 typedef typename boost::add_lvalue_reference<value_type>::type reference; 51 typedef typename boost::add_lvalue_reference<const value_type>::type const_reference; 52 53 template <class U> struct rebind {typedef test_allocator<U> other;}; 54 55 test_allocator() throw() : data_(-1) {} 56 explicit test_allocator(int i) throw() : data_(i) {} 57 test_allocator(const test_allocator& a) throw() 58 : data_(a.data_) {} 59 template <class U> test_allocator(const test_allocator<U>& a) throw() 60 : data_(a.data_) {} 61 ~test_allocator() throw() {data_ = 0;} 62 pointer address(reference x) const {return &x;} 63 const_pointer address(const_reference x) const {return &x;} 64 pointer allocate(size_type n, const void* = 0) 65 { 66 if (count >= throw_after) 67 throw std::bad_alloc(); 68 ++count; 69 return (pointer)std::malloc(n * sizeof(T)); 70 } 71 void deallocate(pointer p, size_type n) 72 {--count; std::free(p);} 73 size_type max_size() const throw() 74 {return UINT_MAX / sizeof(T);} 75 void construct(pointer p, const T& val) 76 {::new(p) T(val);} 77 78 #ifndef BOOST_NO_RVALUE_REFERENCES 79 void construct(pointer p, T&& val) 80 {::new(p) T(boost::move(val));} 81 #elif defined BOOST_THREAD_USES_MOVE 82 void construct(pointer p, ::boost::rv<T>& val) 83 {::new(p) T(boost::move(val));} 84 #else 85 void construct(pointer p, ::boost::detail::thread_move_t<T> val) 86 {::new(p) T(boost::move(val));} 87 #endif // BOOST_NO_RVALUE_REFERENCES 88 89 void destroy(pointer p) {p->~T();} 90 91 friend bool operator==(const test_allocator& x, const test_allocator& y) 92 {return x.data_ == y.data_;} 93 friend bool operator!=(const test_allocator& x, const test_allocator& y) 94 {return !(x == y);} 95 }; 96 97 template <> 98 class test_allocator<void> 99 : public test_alloc_base 100 { 101 int data_; 102 103 template <class U> friend class test_allocator; 104 public: 105 106 typedef unsigned size_type; 107 typedef int difference_type; 108 typedef void value_type; 109 typedef value_type* pointer; 110 typedef const value_type* const_pointer; 111 112 template <class U> struct rebind {typedef test_allocator<U> other;}; 113 114 test_allocator() throw() : data_(-1) {} 115 explicit test_allocator(int i) throw() : data_(i) {} 116 test_allocator(const test_allocator& a) throw() 117 : data_(a.data_) {} 118 template <class U> test_allocator(const test_allocator<U>& a) throw() 119 : data_(a.data_) {} 120 ~test_allocator() throw() {data_ = 0;} 121 122 friend bool operator==(const test_allocator& x, const test_allocator& y) 123 {return x.data_ == y.data_;} 124 friend bool operator!=(const test_allocator& x, const test_allocator& y) 125 {return !(x == y);} 126 }; 127 128 template <class T> 129 class other_allocator 130 { 131 int data_; 132 133 template <class U> friend class other_allocator; 134 135 public: 136 typedef T value_type; 137 138 other_allocator() : data_(-1) {} 139 explicit other_allocator(int i) : data_(i) {} 140 template <class U> other_allocator(const other_allocator<U>& a) 141 : data_(a.data_) {} 142 T* allocate(std::size_t n) 143 {return (T*)std::malloc(n * sizeof(T));} 144 void deallocate(T* p, std::size_t n) 145 {std::free(p);} 146 147 other_allocator select_on_container_copy_construction() const 148 {return other_allocator(-2);} 149 150 friend bool operator==(const other_allocator& x, const other_allocator& y) 151 {return x.data_ == y.data_;} 152 friend bool operator!=(const other_allocator& x, const other_allocator& y) 153 {return !(x == y);} 154 155 typedef boost::true_type propagate_on_container_copy_assignment; 156 typedef boost::true_type propagate_on_container_move_assignment; 157 typedef boost::true_type propagate_on_container_swap; 158 159 #ifdef BOOST_NO_SFINAE_EXPR 160 std::size_t max_size() const 161 {return UINT_MAX / sizeof(T);} 162 #endif // BOOST_NO_SFINAE_EXPR 163 164 }; 165 166 #endif // BOOST_THREAD_TEST_ALLOCATOR_HPP -
../../libs/thread/test/sync/futures/future/dtor_pass.cpp
Property changes on: ../../libs/thread/test/sync/futures/test_allocator.hpp ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 // <boost/thread/future.hpp> 16 17 // class promise<R> 18 19 // ~promise(); 20 21 #define BOOST_THREAD_VERSION 2 22 #include <boost/exception/exception.hpp> 23 24 #include <boost/thread/future.hpp> 25 #include <boost/detail/lightweight_test.hpp> 26 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS 27 #include <libs/thread/test/sync/futures/test_allocator.hpp> 28 #endif 29 30 int main() 31 { 32 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS 33 BOOST_TEST(test_alloc_base::count == 0); 34 { 35 typedef int T; 36 boost::future<T> f; 37 { 38 boost::promise<T> p(boost::container::allocator_arg, test_allocator<T>()); 39 BOOST_TEST(test_alloc_base::count == 1); 40 f = p.get_future(); 41 BOOST_TEST(test_alloc_base::count == 1); 42 BOOST_TEST(f.valid()); 43 } 44 BOOST_TEST(test_alloc_base::count == 1); 45 BOOST_TEST(f.valid()); 46 } 47 BOOST_TEST(test_alloc_base::count == 0); 48 { 49 typedef int& T; 50 boost::future<T> f; 51 { 52 boost::promise<T> p(boost::container::allocator_arg, test_allocator<int>()); 53 BOOST_TEST(test_alloc_base::count == 1); 54 f = p.get_future(); 55 BOOST_TEST(test_alloc_base::count == 1); 56 BOOST_TEST(f.valid()); 57 } 58 BOOST_TEST(test_alloc_base::count == 1); 59 BOOST_TEST(f.valid()); 60 } 61 BOOST_TEST(test_alloc_base::count == 0); 62 { 63 typedef void T; 64 boost::future<T> f; 65 { 66 boost::promise<T> p(boost::container::allocator_arg, test_allocator<T>()); 67 BOOST_TEST(test_alloc_base::count == 1); 68 f = p.get_future(); 69 BOOST_TEST(test_alloc_base::count == 1); 70 BOOST_TEST(f.valid()); 71 } 72 BOOST_TEST(test_alloc_base::count == 1); 73 BOOST_TEST(f.valid()); 74 } 75 BOOST_TEST(test_alloc_base::count == 0); 76 #endif 77 78 return boost::report_errors(); 79 } 80 -
../../libs/thread/test/sync/futures/future/move_assign_pass.cpp
Property changes on: ../../libs/thread/test/sync/futures/future/dtor_pass.cpp ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 // <future> 16 17 // class promise<R> 18 19 // promise& operator=(promise&& rhs); 20 21 #define BOOST_THREAD_VERSION 2 22 #define BOOST_THREAD_FUTURE_USES_ALLOCATORS 23 24 #include <boost/thread/future.hpp> 25 #include <boost/detail/lightweight_test.hpp> 26 27 boost::mutex m0; 28 boost::mutex m1; 29 30 int main() 31 { 32 { 33 typedef int T; 34 boost::promise<T> p; 35 boost::future<T> f0 = p.get_future(); 36 boost::future<T> f; 37 f = boost::move(f0); 38 BOOST_TEST(!f0.valid()); 39 BOOST_TEST(f.valid()); 40 } 41 { 42 typedef int T; 43 boost::future<T> f0; 44 boost::future<T> f; 45 f = boost::move(f0); 46 BOOST_TEST(!f0.valid()); 47 BOOST_TEST(!f.valid()); 48 } 49 { 50 typedef int& T; 51 boost::promise<T> p; 52 boost::future<T> f0 = p.get_future(); 53 boost::future<T> f; 54 f = boost::move(f0); 55 BOOST_TEST(!f0.valid()); 56 BOOST_TEST(f.valid()); 57 } 58 { 59 typedef int& T; 60 boost::future<T> f0; 61 boost::future<T> f; 62 f = boost::move(f0); 63 BOOST_TEST(!f0.valid()); 64 BOOST_TEST(!f.valid()); 65 } 66 { 67 typedef void T; 68 boost::promise<T> p; 69 boost::future<T> f0 = p.get_future(); 70 boost::future<T> f; 71 f = boost::move(f0); 72 BOOST_TEST(!f0.valid()); 73 BOOST_TEST(f.valid()); 74 } 75 { 76 typedef void T; 77 boost::future<T> f0; 78 boost::future<T> f; 79 f = boost::move(f0); 80 BOOST_TEST(!f0.valid()); 81 BOOST_TEST(!f.valid()); 82 } 83 84 85 return boost::report_errors(); 86 87 } 88 -
../../libs/thread/test/sync/futures/future/move_ctor_pass.cpp
Property changes on: ../../libs/thread/test/sync/futures/future/move_assign_pass.cpp ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 // <future> 16 17 // class promise<R> 18 19 // promise(promise&& rhs); 20 21 #define BOOST_THREAD_VERSION 2 22 #define BOOST_THREAD_FUTURE_USES_ALLOCATORS 23 24 #include <boost/thread/future.hpp> 25 #include <boost/detail/lightweight_test.hpp> 26 27 boost::mutex m; 28 29 int main() 30 { 31 { 32 typedef int T; 33 boost::promise<T> p; 34 boost::future<T> f0 = p.get_future(); 35 boost::future<T> f = boost::move(f0); 36 BOOST_TEST(!f0.valid()); 37 BOOST_TEST(f.valid()); 38 } 39 { 40 typedef int T; 41 boost::future<T> f0; 42 boost::future<T> f = boost::move(f0); 43 BOOST_TEST(!f0.valid()); 44 BOOST_TEST(!f.valid()); 45 } 46 { 47 typedef int& T; 48 boost::promise<T> p; 49 boost::future<T> f0 = p.get_future(); 50 boost::future<T> f = boost::move(f0); 51 BOOST_TEST(!f0.valid()); 52 BOOST_TEST(f.valid()); 53 } 54 { 55 typedef int& T; 56 boost::future<T> f0; 57 boost::future<T> f = boost::move(f0); 58 BOOST_TEST(!f0.valid()); 59 BOOST_TEST(!f.valid()); 60 } 61 { 62 typedef void T; 63 boost::promise<T> p; 64 boost::future<T> f0 = p.get_future(); 65 boost::future<T> f = boost::move(f0); 66 BOOST_TEST(!f0.valid()); 67 BOOST_TEST(f.valid()); 68 } 69 { 70 typedef void T; 71 boost::future<T> f0; 72 boost::future<T> f = boost::move(f0); 73 BOOST_TEST(!f0.valid()); 74 BOOST_TEST(!f.valid()); 75 } 76 77 return boost::report_errors(); 78 } 79 -
../../libs/thread/test/sync/futures/future/get_pass.cpp
Property changes on: ../../libs/thread/test/sync/futures/future/move_ctor_pass.cpp ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 // <boost/thread/future.hpp> 16 17 // class promise<R> 18 19 // future<R> get_future(); 20 21 #define BOOST_THREAD_VERSION 2 22 23 #include <boost/thread/future.hpp> 24 #include <boost/thread/thread.hpp> 25 #include <boost/detail/lightweight_test.hpp> 26 27 namespace boost 28 { 29 template <typename T> 30 struct wrap 31 { 32 wrap(T const& v) : value(v){} 33 T value; 34 35 }; 36 37 template <typename T> 38 exception_ptr make_exception_ptr(T v) { 39 return copy_exception(wrap<T>(v)); 40 } 41 } 42 43 void func1(boost::promise<int> p) 44 { 45 boost::this_thread::sleep_for(boost::chrono::milliseconds(500)); 46 p.set_value(3); 47 } 48 49 void func2(boost::promise<int> p) 50 { 51 boost::this_thread::sleep_for(boost::chrono::milliseconds(500)); 52 p.set_exception(boost::make_exception_ptr(3)); 53 } 54 55 int j = 0; 56 57 void func3(boost::promise<int&> p) 58 { 59 boost::this_thread::sleep_for(boost::chrono::milliseconds(500)); 60 j = 5; 61 p.set_value(j); 62 } 63 64 void func4(boost::promise<int&> p) 65 { 66 boost::this_thread::sleep_for(boost::chrono::milliseconds(500)); 67 p.set_exception(boost::make_exception_ptr(3.5)); 68 } 69 70 void func5(boost::promise<void> p) 71 { 72 boost::this_thread::sleep_for(boost::chrono::milliseconds(500)); 73 p.set_value(); 74 } 75 76 void func6(boost::promise<void> p) 77 { 78 boost::this_thread::sleep_for(boost::chrono::milliseconds(500)); 79 p.set_exception(boost::make_exception_ptr('c')); 80 } 81 82 83 int main() 84 { 85 { 86 typedef int T; 87 { 88 boost::promise<T> p; 89 boost::future<T> f = p.get_future(); 90 boost::thread(func1, boost::move(p)).detach(); 91 BOOST_TEST(f.valid()); 92 BOOST_TEST(f.get() == 3); 93 BOOST_TEST(!f.valid()); 94 } 95 { 96 boost::promise<T> p; 97 boost::future<T> f = p.get_future(); 98 boost::thread(func2, boost::move(p)).detach(); 99 try 100 { 101 BOOST_TEST(f.valid()); 102 BOOST_TEST(f.get() == 3); 103 BOOST_TEST(false); 104 } 105 catch (int i) 106 { 107 BOOST_TEST(i == 3); 108 } 109 BOOST_TEST(!f.valid()); 110 } 111 } 112 // { 113 // typedef int& T; 114 // { 115 // boost::promise<T> p; 116 // boost::future<T> f = p.get_future(); 117 // boost::thread(func3, boost::move(p)).detach(); 118 // BOOST_TEST(f.valid()); 119 // BOOST_TEST(f.get() == 5); 120 // BOOST_TEST(!f.valid()); 121 // } 122 // { 123 // boost::promise<T> p; 124 // boost::future<T> f = p.get_future(); 125 // boost::thread(func4, boost::move(p)).detach(); 126 // try 127 // { 128 // BOOST_TEST(f.valid()); 129 // BOOST_TEST(f.get() == 3); 130 // BOOST_TEST(false); 131 // } 132 // catch (double i) 133 // { 134 // BOOST_TEST(i == 3.5); 135 // } 136 // BOOST_TEST(!f.valid()); 137 // } 138 // } 139 // { 140 // typedef void T; 141 // { 142 // boost::promise<T> p; 143 // boost::future<T> f = p.get_future(); 144 // boost::thread(func5, boost::move(p)).detach(); 145 // BOOST_TEST(f.valid()); 146 // f.get(); 147 // BOOST_TEST(!f.valid()); 148 // } 149 // { 150 // boost::promise<T> p; 151 // boost::future<T> f = p.get_future(); 152 // boost::thread(func6, boost::move(p)).detach(); 153 // try 154 // { 155 // BOOST_TEST(f.valid()); 156 // f.get(); 157 // BOOST_TEST(false); 158 // } 159 // catch (char i) 160 // { 161 // BOOST_TEST(i == 'c'); 162 // } 163 // BOOST_TEST(!f.valid()); 164 // } 165 // } 166 167 168 169 return boost::report_errors(); 170 } 171 -
../../libs/thread/test/sync/futures/future/copy_assign_fail.cpp
Property changes on: ../../libs/thread/test/sync/futures/future/get_pass.cpp ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 // <boost/thread/future.hpp> 16 17 // class future<R> 18 19 // future& operator=(const future&) = delete; 20 21 22 #define BOOST_THREAD_VERSION 2 23 #include <boost/thread/future.hpp> 24 #include <boost/detail/lightweight_test.hpp> 25 26 int main() 27 { 28 { 29 typedef int T; 30 boost::promise<T> p; 31 boost::future<T> f0 = p.get_future(); 32 boost::future<T> f; 33 f = f0; 34 } 35 36 return boost::report_errors(); 37 } 38 -
../../libs/thread/test/sync/futures/future/default_pass.cpp
Property changes on: ../../libs/thread/test/sync/futures/future/copy_assign_fail.cpp ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 // <boost/thread/future.hpp> 16 17 // class promise<R> 18 19 // promise(); 20 21 #define BOOST_THREAD_VERSION 2 22 23 #include <boost/thread/future.hpp> 24 #include <boost/detail/lightweight_test.hpp> 25 26 int main() 27 { 28 29 { 30 boost::promise<int> p; 31 boost::future<int> f = p.get_future(); 32 BOOST_TEST(f.valid()); 33 } 34 { 35 boost::promise<int&> p; 36 boost::future<int&> f = p.get_future(); 37 BOOST_TEST(f.valid()); 38 } 39 { 40 boost::promise<void> p; 41 std::cout << __LINE__ << std::endl; 42 boost::future<void> f = p.get_future(); 43 std::cout << __LINE__ << std::endl; 44 BOOST_TEST(f.valid()); 45 } 46 47 return boost::report_errors(); 48 } 49 -
../../libs/thread/test/sync/futures/future/copy_ctor_fail.cpp
Property changes on: ../../libs/thread/test/sync/futures/future/default_pass.cpp ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 // <boost/thread/future.hpp> 16 // class future<R> 17 18 // future(const future&) = delete; 19 20 21 #define BOOST_THREAD_VERSION 2 22 #include <boost/thread/future.hpp> 23 #include <boost/detail/lightweight_test.hpp> 24 25 int main() 26 { 27 { 28 typedef int T; 29 boost::promise<T> p; 30 boost::future<T> f0 = p.get_future(); 31 boost::future<T> f = f0; 32 } 33 34 return boost::report_errors(); 35 } 36 -
../../libs/thread/test/sync/futures/promise/dtor_pass.cpp
Property changes on: ../../libs/thread/test/sync/futures/future/copy_ctor_fail.cpp ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
25 25 26 26 int main() 27 27 { 28 std::cout << __LINE__ << std::endl;29 28 { 30 29 typedef int T; 31 30 boost::future<T> f; … … 36 35 } 37 36 BOOST_TEST(f.get() == 3); 38 37 } 39 std::cout << __LINE__ << std::endl;40 38 { 41 39 typedef int T; 42 40 boost::future<T> f; … … 54 52 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::broken_promise)); 55 53 } 56 54 } 57 58 std::cout << __LINE__ << std::endl;59 55 { 60 56 typedef int& T; 61 57 int i = 4; … … 67 63 } 68 64 BOOST_TEST(&f.get() == &i); 69 65 } 70 std::cout << __LINE__ << std::endl;71 66 { 72 67 typedef int& T; 73 68 boost::future<T> f; … … 85 80 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::broken_promise)); 86 81 } 87 82 } 88 89 std::cout << __LINE__ << std::endl;90 83 { 91 84 typedef void T; 92 85 boost::future<T> f; … … 98 91 f.get(); 99 92 BOOST_TEST(true); 100 93 } 101 std::cout << __LINE__ << std::endl;102 94 { 103 95 typedef void T; 104 96 boost::future<T> f; -
../../libs/thread/test/sync/futures/promise/get_future_pass.cpp
25 25 26 26 int main() 27 27 { 28 // {29 // boost::promise<double> p;30 // boost::future<double> f = p.get_future();31 // p.set_value(105.5);32 // BOOST_TEST(f.get() == 105.5);33 // }34 // {35 // boost::promise<double> p;36 // boost::future<double> f = p.get_future();37 // try38 // {39 // f = p.get_future();40 // BOOST_TEST(false);41 // }42 // catch (const boost::future_error& e)43 // {44 // BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::future_already_retrieved));45 // }46 // }47 28 { 48 29 boost::promise<double> p; 30 boost::future<double> f = p.get_future(); 31 p.set_value(105.5); 32 BOOST_TEST(f.get() == 105.5); 33 } 34 { 35 boost::promise<double> p; 36 boost::future<double> f = p.get_future(); 37 try 38 { 39 f = p.get_future(); 40 BOOST_TEST(false); 41 } 42 catch (const boost::future_error& e) 43 { 44 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::future_already_retrieved)); 45 } 46 } 47 { 48 boost::promise<double> p; 49 49 boost::promise<double> p0 = boost::move(p); 50 50 try 51 51 { -
../../libs/thread/test/sync/futures/promise/move_assign_pass.cpp
19 19 // promise& operator=(promise&& rhs); 20 20 21 21 #define BOOST_THREAD_VERSION 2 22 #define BOOST_THREAD_FUTURE_USES_ALLOCATORS 22 23 23 24 #include <boost/thread/future.hpp> 24 25 #include <boost/detail/lightweight_test.hpp> 26 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS 27 #include <libs/thread/test/sync/futures/test_allocator.hpp> 28 #endif 25 29 26 30 boost::mutex m0; 27 31 boost::mutex m1; 28 32 29 33 int main() 30 34 { 31 //BOOST_TEST(test_alloc_base::count == 0); 35 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS 36 BOOST_TEST(test_alloc_base::count == 0); 32 37 { 33 //boost::promise<int> p0(boost::allocator_arg, test_allocator<int>()); 34 //boost::promise<int> p(boost::allocator_arg, test_allocator<int>()); 38 boost::promise<int> p0(boost::container::allocator_arg, test_allocator<int>()); 39 boost::promise<int> p(boost::container::allocator_arg, test_allocator<int>()); 40 BOOST_TEST(test_alloc_base::count == 2); 41 p = boost::move(p0); 42 BOOST_TEST(test_alloc_base::count == 1); 43 boost::future<int> f = p.get_future(); 44 BOOST_TEST(test_alloc_base::count == 1); 45 BOOST_TEST(f.valid()); 46 try 47 { 48 f = p0.get_future(); 49 BOOST_TEST(false); 50 } 51 catch (const boost::future_error& e) 52 { 53 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 54 } 55 BOOST_TEST(test_alloc_base::count == 1); 56 } 57 BOOST_TEST(test_alloc_base::count == 0); 58 59 { 60 boost::promise<int&> p0(boost::container::allocator_arg, test_allocator<int>()); 61 boost::promise<int&> p(boost::container::allocator_arg, test_allocator<int>()); 62 BOOST_TEST(test_alloc_base::count == 2); 63 p = boost::move(p0); 64 BOOST_TEST(test_alloc_base::count == 1); 65 boost::future<int&> f = p.get_future(); 66 BOOST_TEST(test_alloc_base::count == 1); 67 BOOST_TEST(f.valid()); 68 try 69 { 70 f = p0.get_future(); 71 BOOST_TEST(false); 72 } 73 catch (const boost::future_error& e) 74 { 75 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 76 } 77 BOOST_TEST(test_alloc_base::count == 1); 78 } 79 BOOST_TEST(test_alloc_base::count == 0); 80 { 81 boost::promise<void> p0(boost::container::allocator_arg, test_allocator<void>()); 82 boost::promise<void> p(boost::container::allocator_arg, test_allocator<void>()); 83 BOOST_TEST(test_alloc_base::count == 2); 84 p = boost::move(p0); 85 BOOST_TEST(test_alloc_base::count == 1); 86 boost::future<void> f = p.get_future(); 87 BOOST_TEST(test_alloc_base::count == 1); 88 BOOST_TEST(f.valid()); 89 try 90 { 91 f = p0.get_future(); 92 BOOST_TEST(false); 93 } 94 catch (const boost::future_error& e) 95 { 96 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 97 } 98 BOOST_TEST(test_alloc_base::count == 1); 99 } 100 BOOST_TEST(test_alloc_base::count == 0); 101 102 #endif 103 { 35 104 boost::promise<int> p0; 36 105 boost::promise<int> p; 37 //BOOST_TEST(test_alloc_base::count == 2);38 106 p = boost::move(p0); 39 //BOOST_TEST(test_alloc_base::count == 1);40 107 boost::future<int> f = p.get_future(); 41 //BOOST_TEST(test_alloc_base::count == 1);42 108 BOOST_TEST(f.valid()); 43 109 try 44 110 { … … 49 115 { 50 116 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 51 117 } 52 //BOOST_TEST(test_alloc_base::count == 1);53 118 } 54 //BOOST_TEST(test_alloc_base::count == 0); 119 55 120 { 56 //boost::promise<int&> p0(boost::allocator_arg, test_allocator<int>());57 //boost::promise<int&> p(boost::allocator_arg, test_allocator<int>());58 121 boost::promise<int&> p0; 59 122 boost::promise<int&> p; 60 //BOOST_TEST(test_alloc_base::count == 2);61 123 p = boost::move(p0); 62 //BOOST_TEST(test_alloc_base::count == 1);63 124 boost::future<int&> f = p.get_future(); 64 //BOOST_TEST(test_alloc_base::count == 1);65 125 BOOST_TEST(f.valid()); 66 126 try 67 127 { … … 72 132 { 73 133 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 74 134 } 75 //BOOST_TEST(test_alloc_base::count == 1);76 135 } 77 //BOOST_TEST(test_alloc_base::count == 0);78 136 { 79 //boost::promise<void> p0(boost::allocator_arg, test_allocator<void>());80 //boost::promise<void> p(boost::allocator_arg, test_allocator<void>());81 137 boost::promise<void> p0; 82 138 boost::promise<void> p; 83 //BOOST_TEST(test_alloc_base::count == 2);84 139 p = boost::move(p0); 85 //BOOST_TEST(test_alloc_base::count == 1);86 140 boost::future<void> f = p.get_future(); 87 //BOOST_TEST(test_alloc_base::count == 1);88 141 BOOST_TEST(f.valid()); 89 142 try 90 143 { … … 95 148 { 96 149 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 97 150 } 98 //BOOST_TEST(test_alloc_base::count == 1);99 151 } 100 //BOOST_TEST(test_alloc_base::count == 0);101 152 102 153 return boost::report_errors(); 103 154 -
../../libs/thread/test/sync/futures/promise/use_allocator_pass.cpp
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 // <boost/thread/future.hpp> 16 17 // class promise<R> 18 19 // promise(allocator_arg_t, const Allocator& a); 20 21 #define BOOST_THREAD_VERSION 2 22 23 #include <boost/thread/future.hpp> 24 #include <boost/detail/lightweight_test.hpp> 25 #include <boost/static_assert.hpp> 26 27 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS 28 #include <libs/thread/test/sync/futures/test_allocator.hpp> 29 30 int main() 31 { 32 33 BOOST_STATIC_ASSERT_MSG((boost::container::uses_allocator<boost::promise<int>, test_allocator<int> >::value), ""); 34 BOOST_STATIC_ASSERT_MSG((boost::container::uses_allocator<boost::promise<int&>, test_allocator<int> >::value), ""); 35 BOOST_STATIC_ASSERT_MSG((boost::container::uses_allocator<boost::promise<void>, test_allocator<void> >::value), ""); 36 37 return boost::report_errors(); 38 } 39 40 #else 41 int main() 42 { 43 return boost::report_errors(); 44 } 45 #endif 46 47 -
../../libs/thread/test/sync/futures/promise/move_ctor_pass.cpp
Property changes on: ../../libs/thread/test/sync/futures/promise/use_allocator_pass.cpp ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
19 19 // promise(promise&& rhs); 20 20 21 21 #define BOOST_THREAD_VERSION 2 22 #define BOOST_THREAD_FUTURE_USES_ALLOCATORS 22 23 23 24 #include <boost/thread/future.hpp> 24 25 #include <boost/detail/lightweight_test.hpp> 26 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS 27 #include <libs/thread/test/sync/futures/test_allocator.hpp> 28 #endif 25 29 26 30 boost::mutex m; 27 31 28 32 int main() 29 33 { 34 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS 35 BOOST_TEST(test_alloc_base::count == 0); 36 { 37 boost::promise<int> p0(boost::container::allocator_arg, test_allocator<int>()); 38 boost::promise<int> p(boost::move(p0)); 39 BOOST_TEST(test_alloc_base::count == 1); 40 std::cout << __LINE__ << std::endl; 41 boost::future<int> f = p.get_future(); 42 std::cout << __LINE__ << std::endl; 43 BOOST_TEST(test_alloc_base::count == 1); 44 BOOST_TEST(f.valid()); 45 std::cout << __LINE__ << std::endl; 46 try 47 { 48 f = p0.get_future(); 49 BOOST_TEST(false); 50 } 51 catch (const boost::future_error& e) 52 { 53 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 54 } 55 std::cout << __LINE__ << std::endl; 56 BOOST_TEST(test_alloc_base::count == 1); 57 } 30 58 std::cout << __LINE__ << std::endl; 31 //BOOST_TEST(test_alloc_base::count == 0);59 BOOST_TEST(test_alloc_base::count == 0); 32 60 { 33 //boost::promise<int> p0(boost::allocator_arg, test_allocator<int>()); 34 //boost::promise<int> p(boost::move(p0)); 61 boost::promise<int&> p0(boost::container::allocator_arg, test_allocator<int>()); 62 boost::promise<int&> p(boost::move(p0)); 63 BOOST_TEST(test_alloc_base::count == 1); 64 boost::future<int&> f = p.get_future(); 65 BOOST_TEST(test_alloc_base::count == 1); 66 BOOST_TEST(f.valid()); 67 try 68 { 69 f = p0.get_future(); 70 BOOST_TEST(false); 71 } 72 catch (const boost::future_error& e) 73 { 74 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 75 } 76 BOOST_TEST(test_alloc_base::count == 1); 77 } 78 BOOST_TEST(test_alloc_base::count == 0); 79 { 80 boost::promise<void> p0(boost::container::allocator_arg, test_allocator<void>()); 81 boost::promise<void> p(boost::move(p0)); 82 BOOST_TEST(test_alloc_base::count == 1); 83 boost::future<void> f = p.get_future(); 84 BOOST_TEST(test_alloc_base::count == 1); 85 BOOST_TEST(f.valid()); 86 try 87 { 88 f = p0.get_future(); 89 BOOST_TEST(false); 90 } 91 catch (const boost::future_error& e) 92 { 93 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 94 } 95 BOOST_TEST(test_alloc_base::count == 1); 96 } 97 BOOST_TEST(test_alloc_base::count == 0); 98 #endif 99 { 35 100 boost::promise<int> p0; 36 101 boost::promise<int> p(boost::move(p0)); 37 //BOOST_TEST(test_alloc_base::count == 1);38 102 std::cout << __LINE__ << std::endl; 39 103 boost::future<int> f = p.get_future(); 40 104 std::cout << __LINE__ << std::endl; 41 //BOOST_TEST(test_alloc_base::count == 1);42 105 BOOST_TEST(f.valid()); 43 106 std::cout << __LINE__ << std::endl; 44 107 try … … 51 114 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 52 115 } 53 116 std::cout << __LINE__ << std::endl; 54 //BOOST_TEST(test_alloc_base::count == 1);55 117 } 56 118 std::cout << __LINE__ << std::endl; 57 //BOOST_TEST(test_alloc_base::count == 0);58 119 { 59 //boost::promise<int&> p0(boost::allocator_arg, test_allocator<int>());60 //boost::promise<int&> p(boost::move(p0));61 120 boost::promise<int&> p0; 62 121 boost::promise<int&> p(boost::move(p0)); 63 //BOOST_TEST(test_alloc_base::count == 1);64 122 boost::future<int&> f = p.get_future(); 65 //BOOST_TEST(test_alloc_base::count == 1);66 123 BOOST_TEST(f.valid()); 67 124 try 68 125 { … … 73 130 { 74 131 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 75 132 } 76 //BOOST_TEST(test_alloc_base::count == 1);77 133 } 78 //BOOST_TEST(test_alloc_base::count == 0);79 134 { 80 //boost::promise<void> p0(boost::allocator_arg, test_allocator<void>());81 //boost::promise<void> p(boost::move(p0));82 135 boost::promise<void> p0; 83 136 boost::promise<void> p(boost::move(p0)); 84 //BOOST_TEST(test_alloc_base::count == 1);85 137 boost::future<void> f = p.get_future(); 86 //BOOST_TEST(test_alloc_base::count == 1);87 138 BOOST_TEST(f.valid()); 88 139 try 89 140 { … … 94 145 { 95 146 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state)); 96 147 } 97 //BOOST_TEST(test_alloc_base::count == 1);98 148 } 99 //BOOST_TEST(test_alloc_base::count == 0);100 149 101 102 150 return boost::report_errors(); 103 151 } 104 152 -
../../libs/thread/test/sync/futures/promise/alloc_ctor_pass.cpp
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 // <boost/thread/future.hpp> 16 17 // class promise<R> 18 19 // promise(allocator_arg_t, const Allocator& a); 20 21 #define BOOST_THREAD_VERSION 2 22 23 #include <boost/thread/future.hpp> 24 #include <boost/detail/lightweight_test.hpp> 25 #if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS 26 #include <libs/thread/test/sync/futures/test_allocator.hpp> 27 28 int main() 29 { 30 BOOST_TEST(test_alloc_base::count == 0); 31 { 32 boost::promise<int> p(boost::container::allocator_arg, test_allocator<int>()); 33 BOOST_TEST(test_alloc_base::count == 1); 34 boost::future<int> f = p.get_future(); 35 BOOST_TEST(test_alloc_base::count == 1); 36 BOOST_TEST(f.valid()); 37 } 38 BOOST_TEST(test_alloc_base::count == 0); 39 { 40 boost::promise<int&> p(boost::container::allocator_arg, test_allocator<int>()); 41 BOOST_TEST(test_alloc_base::count == 1); 42 boost::future<int&> f = p.get_future(); 43 BOOST_TEST(test_alloc_base::count == 1); 44 BOOST_TEST(f.valid()); 45 } 46 BOOST_TEST(test_alloc_base::count == 0); 47 { 48 boost::promise<void> p(boost::container::allocator_arg, test_allocator<void>()); 49 BOOST_TEST(test_alloc_base::count == 1); 50 boost::future<void> f = p.get_future(); 51 BOOST_TEST(test_alloc_base::count == 1); 52 BOOST_TEST(f.valid()); 53 } 54 BOOST_TEST(test_alloc_base::count == 0); 55 56 57 return boost::report_errors(); 58 } 59 60 #else 61 int main() 62 { 63 return boost::report_errors(); 64 } 65 #endif 66 67 -
../../libs/thread/test/sync/futures/promise/copy_assign_fail.cpp
Property changes on: ../../libs/thread/test/sync/futures/promise/alloc_ctor_pass.cpp ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
22 22 23 23 int main() 24 24 { 25 26 //BOOST_TEST(test_alloc_base::count == 0);27 25 { 28 //boost::promise<int> p0(boost::allocator_arg, test_allocator<int>());29 //boost::promise<int> p(boost::allocator_arg, test_allocator<int>());30 26 boost::promise<int> p0; 31 27 boost::promise<int> p; 32 //BOOST_TEST(test_alloc_base::count == 2);33 28 p = p0; 34 //BOOST_TEST(test_alloc_base::count == 1);35 boost::future<int> f = p.get_future();36 //BOOST_TEST(test_alloc_base::count == 1);37 BOOST_TEST(f.valid());38 try39 {40 f = p0.get_future();41 BOOST_TEST(false);42 }43 catch (const boost::future_error& e)44 {45 BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));46 }47 //BOOST_TEST(test_alloc_base::count == 1);48 29 } 49 //BOOST_TEST(test_alloc_base::count == 0);50 // {51 // //boost::promise<int&> p0(boost::allocator_arg, test_allocator<int>());52 // //boost::promise<int&> p(boost::allocator_arg, test_allocator<int>());53 // boost::promise<int&> p0;54 // boost::promise<int&> p;55 // //BOOST_TEST(test_alloc_base::count == 2);56 // p = p0;57 // //BOOST_TEST(test_alloc_base::count == 1);58 // boost::future<int&> f = p.get_future();59 // //BOOST_TEST(test_alloc_base::count == 1);60 // BOOST_TEST(f.valid());61 // try62 // {63 // f = p0.get_future();64 // BOOST_TEST(false);65 // }66 // catch (const boost::future_error& e)67 // {68 // BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));69 // }70 // //BOOST_TEST(test_alloc_base::count == 1);71 // }72 // //BOOST_TEST(test_alloc_base::count == 0);73 // {74 // //boost::promise<void> p0(boost::allocator_arg, test_allocator<void>());75 // //boost::promise<void> p(boost::allocator_arg, test_allocator<void>());76 // boost::promise<void> p0;77 // boost::promise<void> p;78 // //BOOST_TEST(test_alloc_base::count == 2);79 // p = p0;80 // //BOOST_TEST(test_alloc_base::count == 1);81 // boost::future<void> f = p.get_future();82 // //BOOST_TEST(test_alloc_base::count == 1);83 // BOOST_TEST(f.valid());84 // try85 // {86 // f = p0.get_future();87 // BOOST_TEST(false);88 // }89 // catch (const boost::future_error& e)90 // {91 // BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));92 // }93 // //BOOST_TEST(test_alloc_base::count == 1);94 // }95 //BOOST_TEST(test_alloc_base::count == 0);96 30 97 98 31 return boost::report_errors(); 99 32 } 100 33 -
../../libs/thread/test/sync/futures/promise/default_pass.cpp
25 25 26 26 int main() 27 27 { 28 std::cout << __LINE__ << std::endl;29 28 30 29 { 31 30 boost::promise<int> p; 32 31 boost::future<int> f = p.get_future(); 33 32 BOOST_TEST(f.valid()); 34 33 } 35 std::cout << __LINE__ << std::endl;36 34 { 37 35 boost::promise<int&> p; 38 36 boost::future<int&> f = p.get_future(); 39 37 BOOST_TEST(f.valid()); 40 38 } 41 std::cout << __LINE__ << std::endl;42 39 { 43 40 boost::promise<void> p; 44 41 std::cout << __LINE__ << std::endl; -
../../libs/thread/test/sync/futures/promise/copy_ctor_fail.cpp
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 // <boost/thread/future.hpp> 16 // class promise<R> 17 // promise& operator=(const promise& rhs) = delete; 18 19 #define BOOST_THREAD_VERSION 2 20 #include <boost/thread/future.hpp> 21 #include <boost/detail/lightweight_test.hpp> 22 23 int main() 24 { 25 { 26 boost::promise<int> p0; 27 boost::promise<int> p(p0); 28 } 29 30 return boost::report_errors(); 31 } 32 -
../../libs/thread/test/Jamfile.v2
Property changes on: ../../libs/thread/test/sync/futures/promise/copy_ctor_fail.cpp ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
165 165 test-suite futures 166 166 : 167 167 # [ thread-run2 ./sync/futures/async/async_pass.cpp : async__async_p ] 168 168 169 [ thread-compile-fail-V2 ./sync/futures/promise/copy_assign_fail.cpp : : promise__copy_assign_f ] 170 [ thread-compile-fail-V2 ./sync/futures/promise/copy_ctor_fail.cpp : : promise__copy_ctor_f ] 171 [ thread-run2 ./sync/futures/promise/alloc_ctor_pass.cpp : promise__alloc_ctor_p ] 169 172 [ thread-run2 ./sync/futures/promise/default_pass.cpp : promise__default_p ] 170 173 [ thread-run2 ./sync/futures/promise/dtor_pass.cpp : promise__dtor_p ] 171 174 [ thread-run2 ./sync/futures/promise/get_future_pass.cpp : promise__get_future_p ] 172 175 [ thread-run2 ./sync/futures/promise/move_ctor_pass.cpp : promise__move_ctor_p ] 173 176 [ thread-run2 ./sync/futures/promise/move_assign_pass.cpp : promise__move_asign_p ] 177 [ thread-run2 ./sync/futures/promise/use_allocator_pass.cpp : promise__use_allocator_p ] 174 178 179 [ thread-compile-fail-V2 ./sync/futures/future/copy_assign_fail.cpp : : future__copy_assign_f ] 180 [ thread-compile-fail-V2 ./sync/futures/future/copy_ctor_fail.cpp : : future__copy_ctor_f ] 181 [ thread-run2 ./sync/futures/future/default_pass.cpp : future__default_p ] 182 [ thread-run2 ./sync/futures/future/dtor_pass.cpp : future__dtor_p ] 183 #[ thread-run2 ./sync/futures/future/get_pass.cpp : future__get_p ] 184 [ thread-run2 ./sync/futures/future/move_ctor_pass.cpp : future__move_ctor_p ] 185 [ thread-run2 ./sync/futures/future/move_assign_pass.cpp : future__move_asign_p ] 175 186 [ thread-run2 ./sync/futures/future/share_pass.cpp : future__share_p ] 176 187 177 188 ; -
../../libs/thread/doc/future_ref.qbk
44 44 template <typename R> 45 45 void swap(promise<R>& x, promise<R>& y) noexcept; 46 46 47 //template <class R, class Alloc> 48 //struct uses_allocator<promise<R>, Alloc>; // NOT YET IMPLEMENTED 47 namespace container { 48 template <class R, class Alloc> 49 struct uses_allocator<promise<R>, Alloc>:: true_type; 50 } 49 51 50 52 template <typename R> 51 53 class future; … … 703 705 public: 704 706 705 707 promise(); 706 // template <class Allocator> explicit promise(Allocator a); // NOT YET IMPLEMENTED 708 template <class Allocator> 709 explicit promise(allocator_arg_t, Allocator a); 707 710 promise & operator=(const promise & rhs);// = delete; 708 711 promise(const promise & rhs);// = delete; 709 712 ~promise(); … … 744 747 745 748 [endsect] 746 749 750 [section:alloc_constructor Allocator Constructor] 751 752 template <class Allocator> 753 explicit promise(allocator_arg_t, Allocator a); 754 755 [variablelist 756 757 [[Effects:] [Constructs a new __promise__ with no associated result using the allocator `a`.]] 758 759 [[Throws:] [Nothing.]] 760 761 ] 762 763 [endsect] 764 765 766 747 767 [section:move_constructor Move Constructor] 748 768 749 769 promise(promise && other); -
../../libs/thread/doc/changes.qbk
21 21 * [@http://svn.boost.org/trac/boost/ticket/6217 #6217] Enhance Boost.Thread shared mutex interface following Howard Hinnant proposal. 22 22 * [@http://svn.boost.org/trac/boost/ticket/6224 #6224] c++11 compliance: Add the use of standard noexcept on compilers supporting them. 23 23 * [@http://svn.boost.org/trac/boost/ticket/6226 #6226] c++11 compliance: Add explicit bool conversion from locks. 24 * [@http://svn.boost.org/trac/boost/ticket/6228 #6228] Add promise constructor with allocator following the standard c++11. 24 25 * [@http://svn.boost.org/trac/boost/ticket/6230 #6230] c++11 compliance: Follows the exception reporting mechanism as defined in the c++11. 25 26 * [@http://svn.boost.org/trac/boost/ticket/6272 #6272] c++11 compliance: Add thread::id hash specialization. 26 27 * [@http://svn.boost.org/trac/boost/ticket/6273 #6273] c++11 compliance: Add cv_status enum class and use it on the conditions wait functions. … … 181 182 * [@http://svn.boost.org/trac/boost/ticket/6342 #6342] Breaking change: Adapt the one_flag and call_once to the c++11 interface. 182 183 183 184 * [@http://svn.boost.org/trac/boost/ticket/6227 #6227] Use of variadic templates on Generic Locking Algorithms on compilers providing them. 184 * [@http://svn.boost.org/trac/boost/ticket/6228 #6228] Add promise and futures constructor with allocator following the standard c++11.185 185 * [@http://svn.boost.org/trac/boost/ticket/6270 #6270] Add thread constructor from movable callable and movable arguments following C++11. 186 186 187 187