Ticket #6228: 6228.patch

File 6228.patch, 53.6 KB (added by viboes, 11 years ago)
  • future.hpp

     
    3636#include <boost/chrono/system_clocks.hpp>
    3737#endif
    3838
     39#if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS
     40#include <boost/thread/detail/memory.hpp>
     41#endif
     42
    3943#if BOOST_THREAD_VERSION==1
    4044#define BOOST_THREAD_FUTURE unique_future
    4145#else
     
    556560            future_object& operator=(future_object const&);
    557561        };
    558562
     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        };
    559574        class future_waiter
    560575        {
    561576            struct registered_waiter;
     
    12571272        }
    12581273
    12591274    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;
    12611282
     1283          future_ = future_ptr(::new(a2.allocate(1)) detail::future_object<R>(), D(a2, 1) );
     1284          future_obtained = false;
     1285        }
     1286#endif
    12621287        promise():
    12631288#if BOOST_THREAD_VERSION==1
    12641289            future_(),
    12651290#else
    1266             future_(new detail::future_object<R>),
     1291            future_(new detail::future_object<R>()),
    12671292#endif
    12681293            future_obtained(false)
    12691294        {}
     
    14601485#endif
    14611486        }
    14621487    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;
    14641495
     1496          future_ = future_ptr(::new(a2.allocate(1)) detail::future_object<void>(), D(a2, 1) );
     1497          future_obtained = false;
     1498        }
     1499#endif
    14651500        promise():
    14661501#if BOOST_THREAD_VERSION==1
    14671502            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
     25class test_alloc_base
     26{
     27public:
     28    static int count;
     29public:
     30    static int throw_after;
     31};
     32
     33int test_alloc_base::count = 0;
     34int test_alloc_base::throw_after = INT_MAX;
     35
     36template <class T>
     37class test_allocator
     38    : public test_alloc_base
     39{
     40    int data_;
     41
     42    template <class U> friend class test_allocator;
     43public:
     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
     97template <>
     98class test_allocator<void>
     99    : public test_alloc_base
     100{
     101    int data_;
     102
     103    template <class U> friend class test_allocator;
     104public:
     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
     128template <class T>
     129class other_allocator
     130{
     131    int data_;
     132
     133    template <class U> friend class other_allocator;
     134
     135public:
     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
     30int 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
     27boost::mutex m0;
     28boost::mutex m1;
     29
     30int 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
     27boost::mutex m;
     28
     29int 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
     27namespace boost
     28{
     29template <typename T>
     30struct wrap
     31{
     32  wrap(T const& v) : value(v){}
     33  T value;
     34
     35};
     36
     37template <typename T>
     38exception_ptr make_exception_ptr(T v) {
     39  return copy_exception(wrap<T>(v));
     40}
     41}
     42
     43void func1(boost::promise<int> p)
     44{
     45    boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
     46    p.set_value(3);
     47}
     48
     49void 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
     55int j = 0;
     56
     57void 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
     64void 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
     70void func5(boost::promise<void> p)
     71{
     72    boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
     73    p.set_value();
     74}
     75
     76void 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
     83int 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
     26int 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
     26int 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
     25int 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
    
     
    2525
    2626int main()
    2727{
    28   std::cout << __LINE__ << std::endl;
    2928  {
    3029      typedef int T;
    3130      boost::future<T> f;
     
    3635      }
    3736      BOOST_TEST(f.get() == 3);
    3837  }
    39   std::cout << __LINE__ << std::endl;
    4038  {
    4139      typedef int T;
    4240      boost::future<T> f;
     
    5452          BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::broken_promise));
    5553      }
    5654  }
    57 
    58   std::cout << __LINE__ << std::endl;
    5955  {
    6056      typedef int& T;
    6157      int i = 4;
     
    6763      }
    6864      BOOST_TEST(&f.get() == &i);
    6965  }
    70   std::cout << __LINE__ << std::endl;
    7166  {
    7267      typedef int& T;
    7368      boost::future<T> f;
     
    8580          BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::broken_promise));
    8681      }
    8782  }
    88 
    89   std::cout << __LINE__ << std::endl;
    9083  {
    9184      typedef void T;
    9285      boost::future<T> f;
     
    9891      f.get();
    9992      BOOST_TEST(true);
    10093  }
    101   std::cout << __LINE__ << std::endl;
    10294  {
    10395      typedef void T;
    10496      boost::future<T> f;
  • ../../libs/thread/test/sync/futures/promise/get_future_pass.cpp

     
    2525
    2626int main()
    2727{
    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 //      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 //  }
    4728  {
    4829      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;
    4949      boost::promise<double> p0 = boost::move(p);
    5050      try
    5151      {
  • ../../libs/thread/test/sync/futures/promise/move_assign_pass.cpp

     
    1919// promise& operator=(promise&& rhs);
    2020
    2121#define BOOST_THREAD_VERSION 2
     22#define BOOST_THREAD_FUTURE_USES_ALLOCATORS
    2223
    2324#include <boost/thread/future.hpp>
    2425#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
    2529
    2630boost::mutex m0;
    2731boost::mutex m1;
    2832
    2933int main()
    3034{
    31   //BOOST_TEST(test_alloc_base::count == 0);
     35#if defined BOOST_THREAD_FUTURE_USES_ALLOCATORS
     36  BOOST_TEST(test_alloc_base::count == 0);
    3237  {
    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  {
    35104    boost::promise<int> p0;
    36105    boost::promise<int> p;
    37     //BOOST_TEST(test_alloc_base::count == 2);
    38106    p = boost::move(p0);
    39     //BOOST_TEST(test_alloc_base::count == 1);
    40107    boost::future<int> f = p.get_future();
    41     //BOOST_TEST(test_alloc_base::count == 1);
    42108    BOOST_TEST(f.valid());
    43109    try
    44110    {
     
    49115    {
    50116      BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
    51117    }
    52     //BOOST_TEST(test_alloc_base::count == 1);
    53118  }
    54   //BOOST_TEST(test_alloc_base::count == 0);
     119
    55120  {
    56     //boost::promise<int&> p0(boost::allocator_arg, test_allocator<int>());
    57     //boost::promise<int&> p(boost::allocator_arg, test_allocator<int>());
    58121    boost::promise<int&> p0;
    59122    boost::promise<int&> p;
    60     //BOOST_TEST(test_alloc_base::count == 2);
    61123    p = boost::move(p0);
    62     //BOOST_TEST(test_alloc_base::count == 1);
    63124    boost::future<int&> f = p.get_future();
    64     //BOOST_TEST(test_alloc_base::count == 1);
    65125    BOOST_TEST(f.valid());
    66126    try
    67127    {
     
    72132    {
    73133      BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
    74134    }
    75     //BOOST_TEST(test_alloc_base::count == 1);
    76135  }
    77   //BOOST_TEST(test_alloc_base::count == 0);
    78136  {
    79     //boost::promise<void> p0(boost::allocator_arg, test_allocator<void>());
    80     //boost::promise<void> p(boost::allocator_arg, test_allocator<void>());
    81137    boost::promise<void> p0;
    82138    boost::promise<void> p;
    83     //BOOST_TEST(test_alloc_base::count == 2);
    84139    p = boost::move(p0);
    85     //BOOST_TEST(test_alloc_base::count == 1);
    86140    boost::future<void> f = p.get_future();
    87     //BOOST_TEST(test_alloc_base::count == 1);
    88141    BOOST_TEST(f.valid());
    89142    try
    90143    {
     
    95148    {
    96149      BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
    97150    }
    98     //BOOST_TEST(test_alloc_base::count == 1);
    99151  }
    100   //BOOST_TEST(test_alloc_base::count == 0);
    101152
    102153  return boost::report_errors();
    103154
  • ../../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
     30int 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
     41int 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
    
     
    1919// promise(promise&& rhs);
    2020
    2121#define BOOST_THREAD_VERSION 2
     22#define BOOST_THREAD_FUTURE_USES_ALLOCATORS
    2223
    2324#include <boost/thread/future.hpp>
    2425#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
    2529
    2630boost::mutex m;
    2731
    2832int main()
    2933{
     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  }
    3058  std::cout << __LINE__ << std::endl;
    31   //BOOST_TEST(test_alloc_base::count == 0);
     59  BOOST_TEST(test_alloc_base::count == 0);
    3260  {
    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  {
    35100    boost::promise<int> p0;
    36101    boost::promise<int> p(boost::move(p0));
    37     //BOOST_TEST(test_alloc_base::count == 1);
    38102    std::cout << __LINE__ << std::endl;
    39103    boost::future<int> f = p.get_future();
    40104    std::cout << __LINE__ << std::endl;
    41     //BOOST_TEST(test_alloc_base::count == 1);
    42105    BOOST_TEST(f.valid());
    43106    std::cout << __LINE__ << std::endl;
    44107    try
     
    51114      BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
    52115    }
    53116    std::cout << __LINE__ << std::endl;
    54     //BOOST_TEST(test_alloc_base::count == 1);
    55117  }
    56118  std::cout << __LINE__ << std::endl;
    57   //BOOST_TEST(test_alloc_base::count == 0);
    58119  {
    59     //boost::promise<int&> p0(boost::allocator_arg, test_allocator<int>());
    60     //boost::promise<int&> p(boost::move(p0));
    61120    boost::promise<int&> p0;
    62121    boost::promise<int&> p(boost::move(p0));
    63     //BOOST_TEST(test_alloc_base::count == 1);
    64122    boost::future<int&> f = p.get_future();
    65     //BOOST_TEST(test_alloc_base::count == 1);
    66123    BOOST_TEST(f.valid());
    67124    try
    68125    {
     
    73130    {
    74131      BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
    75132    }
    76     //BOOST_TEST(test_alloc_base::count == 1);
    77133  }
    78   //BOOST_TEST(test_alloc_base::count == 0);
    79134  {
    80     //boost::promise<void> p0(boost::allocator_arg, test_allocator<void>());
    81     //boost::promise<void> p(boost::move(p0));
    82135    boost::promise<void> p0;
    83136    boost::promise<void> p(boost::move(p0));
    84     //BOOST_TEST(test_alloc_base::count == 1);
    85137    boost::future<void> f = p.get_future();
    86     //BOOST_TEST(test_alloc_base::count == 1);
    87138    BOOST_TEST(f.valid());
    88139    try
    89140    {
     
    94145    {
    95146      BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::no_state));
    96147    }
    97     //BOOST_TEST(test_alloc_base::count == 1);
    98148  }
    99   //BOOST_TEST(test_alloc_base::count == 0);
    100149
    101 
    102150  return boost::report_errors();
    103151}
    104152
  • ../../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
     28int 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
     61int 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
    
     
    2222
    2323int main()
    2424{
    25 
    26   //BOOST_TEST(test_alloc_base::count == 0);
    2725  {
    28     //boost::promise<int> p0(boost::allocator_arg, test_allocator<int>());
    29     //boost::promise<int> p(boost::allocator_arg, test_allocator<int>());
    3026    boost::promise<int> p0;
    3127    boost::promise<int> p;
    32     //BOOST_TEST(test_alloc_base::count == 2);
    3328    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     try
    39     {
    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);
    4829  }
    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 //    try
    62 //    {
    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 //    try
    85 //    {
    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);
    9630
    97 
    9831  return boost::report_errors();
    9932}
    10033
  • ../../libs/thread/test/sync/futures/promise/default_pass.cpp

     
    2525
    2626int main()
    2727{
    28   std::cout << __LINE__ << std::endl;
    2928
    3029  {
    3130      boost::promise<int> p;
    3231      boost::future<int> f = p.get_future();
    3332      BOOST_TEST(f.valid());
    3433  }
    35   std::cout << __LINE__ << std::endl;
    3634  {
    3735      boost::promise<int&> p;
    3836      boost::future<int&> f = p.get_future();
    3937      BOOST_TEST(f.valid());
    4038  }
    41   std::cout << __LINE__ << std::endl;
    4239  {
    4340      boost::promise<void> p;
    4441      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
     23int 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
    
     
    165165    test-suite futures
    166166    :
    167167    #      [ thread-run2 ./sync/futures/async/async_pass.cpp : async__async_p ]
     168
    168169          [ 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 ]
    169172          [ thread-run2 ./sync/futures/promise/default_pass.cpp : promise__default_p ]
    170173          [ thread-run2 ./sync/futures/promise/dtor_pass.cpp : promise__dtor_p ]
    171174          [ thread-run2 ./sync/futures/promise/get_future_pass.cpp : promise__get_future_p ]
    172175          [ thread-run2 ./sync/futures/promise/move_ctor_pass.cpp : promise__move_ctor_p ]
    173176          [ 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 ]
    174178
     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 ]
    175186          [ thread-run2 ./sync/futures/future/share_pass.cpp : future__share_p ]
    176187
    177188    ;
  • ../../libs/thread/doc/future_ref.qbk

     
    4444    template <typename R>
    4545    void swap(promise<R>& x, promise<R>& y) noexcept;
    4646
    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    }
    4951
    5052    template <typename R>
    5153    class future;
     
    703705    public:
    704706
    705707        promise();
    706         // template <class Allocator> explicit promise(Allocator a); // NOT YET IMPLEMENTED
     708        template <class Allocator>
     709        explicit promise(allocator_arg_t, Allocator a);
    707710        promise & operator=(const promise & rhs);// = delete;
    708711        promise(const promise & rhs);// = delete;
    709712        ~promise();
     
    744747
    745748[endsect]
    746749
     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
    747767[section:move_constructor Move Constructor]
    748768
    749769    promise(promise && other);
  • ../../libs/thread/doc/changes.qbk

     
    2121* [@http://svn.boost.org/trac/boost/ticket/6217 #6217] Enhance Boost.Thread shared mutex interface following Howard Hinnant proposal.
    2222* [@http://svn.boost.org/trac/boost/ticket/6224 #6224] c++11 compliance: Add the use of standard noexcept on compilers supporting them.
    2323* [@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.
    2425* [@http://svn.boost.org/trac/boost/ticket/6230 #6230] c++11 compliance: Follows the exception reporting mechanism as defined in the c++11.
    2526* [@http://svn.boost.org/trac/boost/ticket/6272 #6272] c++11 compliance: Add thread::id hash specialization.
    2627* [@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.
     
    181182  * [@http://svn.boost.org/trac/boost/ticket/6342 #6342] Breaking change: Adapt the one_flag and call_once to the c++11 interface.
    182183
    183184  * [@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.
    185185  * [@http://svn.boost.org/trac/boost/ticket/6270 #6270] Add thread constructor from movable callable and movable arguments following C++11.
    186186       
    187187