Commit b3eed6fe by Jonathan Wakely Committed by Jonathan Wakely

re PR libstdc++/42201 ([C++0x] std::vector<std::unique_future<T>>::push_back fails)

2010-01-21  Jonathan Wakely  <jwakely.gcc@gmail.com>

        PR libstdc++/42201
	* include/std/future: Update to latest WP.
	* src/functexcept.cc (__throw_future_error): Use make_error_code.
	* testsuite/30_threads/async/any.cc: New.
	* testsuite/30_threads/async/async.cc: New.
	* testsuite/30_threads/async/sync.cc: New.
	* testsuite/30_threads/packaged_task/cons/alloc.cc: New.
	* testsuite/30_threads/packaged_task/cons/assign_neg.cc: Adjust.
	* testsuite/30_threads/packaged_task/cons/copy_neg.cc: Adjust.
	* testsuite/30_threads/packaged_task/members/get_future.cc: Adjust.
	* testsuite/30_threads/packaged_task/members/get_future2.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/invoke.cc: Adjust.
	* testsuite/30_threads/packaged_task/members/invoke2.cc: Adjust.
	* testsuite/30_threads/packaged_task/members/invoke3.cc: Adjust.
	* testsuite/30_threads/packaged_task/members/invoke4.cc: Adjust.
	* testsuite/30_threads/packaged_task/members/reset.cc: Adjust.
	* testsuite/30_threads/packaged_task/members/reset2.cc: Adjust.
	* testsuite/30_threads/shared_future/cons/assign_neg.cc: Remove.
	* testsuite/30_threads/shared_future/cons/default_neg.cc: Remove.
	* testsuite/30_threads/shared_future/cons/default.cc: New.
	* testsuite/30_threads/shared_future/cons/assign.cc: New.
	* testsuite/30_threads/shared_future/cons/copy.cc: Adjust.
	* testsuite/30_threads/shared_future/cons/move.cc: Adjust.
	* testsuite/30_threads/shared_future/cons/move_assign.cc: New.
	* testsuite/30_threads/shared_future/members/is_ready.cc: Remove.
	* testsuite/30_threads/shared_future/members/has_value.cc: Remove.
	* testsuite/30_threads/shared_future/members/has_exception.cc: Remove.
	* testsuite/30_threads/shared_future/members/valid.cc: New.
	* testsuite/30_threads/unique_future/cons/default_neg.cc: Remove.
	* testsuite/30_threads/unique_future/cons/default.cc: New.
	* testsuite/30_threads/unique_future/cons/move_assign.cc: New.
	* testsuite/30_threads/unique_future/cons/assign_neg.cc: Adjust.
	* testsuite/30_threads/unique_future/cons/copy_neg.cc: Adjust.
	* testsuite/30_threads/unique_future/cons/move.cc: Adjust.
	* testsuite/30_threads/unique_future/requirements/
        explicit_instantiation.cc: Adjust.
	* testsuite/30_threads/unique_future/members/is_ready.cc: Remove.
	* testsuite/30_threads/unique_future/members/has_value.cc: Remove.
	* testsuite/30_threads/unique_future/members/has_exception.cc: Remove.
	* testsuite/30_threads/unique_future/members/valid.cc: New.
	* testsuite/30_threads/unique_future/members/get.cc: Adjust.
	* testsuite/30_threads/unique_future/members/get2.cc: Adjust.
	* testsuite/30_threads/unique_future/members/wait.cc: Adjust.
	* testsuite/30_threads/unique_future/members/wait_for.cc: Adjust.
	* testsuite/30_threads/unique_future/members/wait_until.cc: Adjust.
	* testsuite/30_threads/headers/future/types_std_c++0x.cc: Adjust.
	* testsuite/30_threads/promise/cons/alloc.cc: New.
	* testsuite/30_threads/promise/cons/assign_neg.cc: Adjust.
	* testsuite/30_threads/promise/cons/copy_neg.cc: Adjust.
	* testsuite/30_threads/promise/cons/move.cc: Adjust.
	* testsuite/30_threads/promise/cons/move_assign.cc: Adjust.
	* testsuite/30_threads/promise/members/get_future.cc: Adjust.
	* testsuite/30_threads/promise/members/set_value.cc: Adjust.
	* testsuite/30_threads/promise/members/set_exception.cc: Adjust.
	* testsuite/30_threads/promise/members/set_exception2.cc: Adjust.
	* testsuite/30_threads/promise/members/set_value2.cc: Adjust.
	* testsuite/30_threads/promise/members/set_value3.cc: Adjust.
	* testsuite/30_threads/promise/members/swap.cc: Adjust.

From-SVN: r156097
parent 4227d4a1
2010-01-21 Jonathan Wakely <jwakely.gcc@gmail.com>
PR libstdc++/42201
* include/std/future: Update to latest WP.
* src/functexcept.cc (__throw_future_error): Use make_error_code.
* testsuite/30_threads/async/any.cc: New.
* testsuite/30_threads/async/async.cc: New.
* testsuite/30_threads/async/sync.cc: New.
* testsuite/30_threads/packaged_task/cons/alloc.cc: New.
* testsuite/30_threads/packaged_task/cons/assign_neg.cc: Adjust.
* testsuite/30_threads/packaged_task/cons/copy_neg.cc: Adjust.
* testsuite/30_threads/packaged_task/members/get_future.cc: Adjust.
* testsuite/30_threads/packaged_task/members/get_future2.cc: Likewise.
* testsuite/30_threads/packaged_task/members/invoke.cc: Adjust.
* testsuite/30_threads/packaged_task/members/invoke2.cc: Adjust.
* testsuite/30_threads/packaged_task/members/invoke3.cc: Adjust.
* testsuite/30_threads/packaged_task/members/invoke4.cc: Adjust.
* testsuite/30_threads/packaged_task/members/reset.cc: Adjust.
* testsuite/30_threads/packaged_task/members/reset2.cc: Adjust.
* testsuite/30_threads/shared_future/cons/assign_neg.cc: Remove.
* testsuite/30_threads/shared_future/cons/default_neg.cc: Remove.
* testsuite/30_threads/shared_future/cons/default.cc: New.
* testsuite/30_threads/shared_future/cons/assign.cc: New.
* testsuite/30_threads/shared_future/cons/copy.cc: Adjust.
* testsuite/30_threads/shared_future/cons/move.cc: Adjust.
* testsuite/30_threads/shared_future/cons/move_assign.cc: New.
* testsuite/30_threads/shared_future/members/is_ready.cc: Remove.
* testsuite/30_threads/shared_future/members/has_value.cc: Remove.
* testsuite/30_threads/shared_future/members/has_exception.cc: Remove.
* testsuite/30_threads/shared_future/members/valid.cc: New.
* testsuite/30_threads/unique_future/cons/default_neg.cc: Remove.
* testsuite/30_threads/unique_future/cons/default.cc: New.
* testsuite/30_threads/unique_future/cons/move_assign.cc: New.
* testsuite/30_threads/unique_future/cons/assign_neg.cc: Adjust.
* testsuite/30_threads/unique_future/cons/copy_neg.cc: Adjust.
* testsuite/30_threads/unique_future/cons/move.cc: Adjust.
* testsuite/30_threads/unique_future/requirements/
explicit_instantiation.cc: Adjust.
* testsuite/30_threads/unique_future/members/is_ready.cc: Remove.
* testsuite/30_threads/unique_future/members/has_value.cc: Remove.
* testsuite/30_threads/unique_future/members/has_exception.cc: Remove.
* testsuite/30_threads/unique_future/members/valid.cc: New.
* testsuite/30_threads/unique_future/members/get.cc: Adjust.
* testsuite/30_threads/unique_future/members/get2.cc: Adjust.
* testsuite/30_threads/unique_future/members/wait.cc: Adjust.
* testsuite/30_threads/unique_future/members/wait_for.cc: Adjust.
* testsuite/30_threads/unique_future/members/wait_until.cc: Adjust.
* testsuite/30_threads/headers/future/types_std_c++0x.cc: Adjust.
* testsuite/30_threads/promise/cons/alloc.cc: New.
* testsuite/30_threads/promise/cons/assign_neg.cc: Adjust.
* testsuite/30_threads/promise/cons/copy_neg.cc: Adjust.
* testsuite/30_threads/promise/cons/move.cc: Adjust.
* testsuite/30_threads/promise/cons/move_assign.cc: Adjust.
* testsuite/30_threads/promise/members/get_future.cc: Adjust.
* testsuite/30_threads/promise/members/set_value.cc: Adjust.
* testsuite/30_threads/promise/members/set_exception.cc: Adjust.
* testsuite/30_threads/promise/members/set_exception2.cc: Adjust.
* testsuite/30_threads/promise/members/set_value2.cc: Adjust.
* testsuite/30_threads/promise/members/set_value3.cc: Adjust.
* testsuite/30_threads/promise/members/swap.cc: Adjust.
2010-01-20 Janis Johnson <janis187@us.ibm.com> 2010-01-20 Janis Johnson <janis187@us.ibm.com>
Paolo Carlini <paolo.carlini@oracle.com> Paolo Carlini <paolo.carlini@oracle.com>
......
...@@ -103,7 +103,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -103,7 +103,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
void void
__throw_future_error(int __i) __throw_future_error(int __i)
{ throw future_error(future_errc(__i)); } { throw future_error(make_error_code(future_errc(__i))); }
void void
__throw_bad_function_call() __throw_bad_function_call()
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" } // { dg-require-atomic-builtins "" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -27,44 +27,32 @@ ...@@ -27,44 +27,32 @@
#include <future> #include <future>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
void test01() struct sum {
{ typedef int result_type;
bool test __attribute__((unused)) = true; int operator()(int i, int& j, const int& k) { return i + j + k; }
};
std::promise<int> p1;
std::shared_future<int> f1(p1.get_future());
std::shared_future<int> f2(f1);
VERIFY( !f1.has_exception() );
VERIFY( !f2.has_exception() );
p1.set_exception(std::copy_exception(1));
VERIFY( f1.has_exception() ); void test01()
VERIFY( f2.has_exception() );
}
void test02()
{ {
std::promise<int> p1;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::shared_future<int> f1(p1.get_future()); using namespace std;
std::shared_future<int> f2(f1);
VERIFY( !f1.has_exception() ); int a = 1;
VERIFY( !f2.has_exception() ); int b = 10;
int c = 100;
future<int> f1 = async(launch::any, sum(), a, ref(b), cref(c));
future<int> f2 = async(sum(), a, ref(b), cref(c));
p1.set_value(1); VERIFY( f1.valid() );
VERIFY( f2.valid() );
VERIFY( !f1.has_exception() ); int r1 = f1.get();
VERIFY( !f2.has_exception() ); int r2 = f2.get();
VERIFY( r1 == r2 );
} }
int main() int main()
{ {
test01(); test01();
test02();
return 0; return 0;
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" } // { dg-require-atomic-builtins "" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -27,38 +27,31 @@ ...@@ -27,38 +27,31 @@
#include <future> #include <future>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
void test01() using namespace std;
{
bool test __attribute__((unused)) = true;
std::promise<int> p1;
std::unique_future<int> f1(p1.get_future());
VERIFY( !f1.has_exception() );
p1.set_exception(std::copy_exception(1));
VERIFY( f1.has_exception() ); struct work {
} typedef void result_type;
void operator()(mutex& m, condition_variable& cv)
{
unique_lock<mutex> l(m);
cv.notify_one();
}
};
void test02() void test01()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int> p1; mutex m;
std::unique_future<int> f1(p1.get_future()); condition_variable cv;
unique_lock<mutex> l(m);
VERIFY( !f1.has_exception() ); future<void> f1 = async(launch::async, work(), ref(m), ref(cv));
cv.wait(l);
p1.set_value(1); f1.get();
VERIFY( !f1.has_exception() );
} }
int main() int main()
{ {
test01(); test01();
test02();
return 0; return 0;
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" } // { dg-require-atomic-builtins "" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -27,39 +27,28 @@ ...@@ -27,39 +27,28 @@
#include <future> #include <future>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
void test01() struct sum {
{ typedef int result_type;
bool test __attribute__((unused)) = true; int operator()(int i, int& j, const int& k) { return i + j + k; }
};
std::promise<int> p1;
std::unique_future<int> f1(p1.get_future());
VERIFY( !f1.has_value() );
p1.set_value(1);
VERIFY( f1.has_value() ); void test01()
}
void test02()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int> p1; using namespace std;
std::unique_future<int> f1(p1.get_future());
VERIFY( !f1.has_value() ); int a = 1;
int b = 10;
int c = 100;
future<int> f1 = async(launch::sync, sum(), a, ref(b), cref(c));
p1.set_exception(std::copy_exception(1)); VERIFY( f1.valid() );
VERIFY( f1.get() == 111 );
VERIFY( !f1.has_value() );
} }
int main() int main()
{ {
test01(); test01();
test02();
return 0; return 0;
} }
...@@ -31,9 +31,9 @@ void test01() ...@@ -31,9 +31,9 @@ void test01()
typedef std::future_error error_t; typedef std::future_error error_t;
typedef std::unique_future<int> uniq_t; typedef std::future<int> uniq_t;
typedef std::unique_future<int&> uniqr_t; typedef std::future<int&> uniqr_t;
typedef std::unique_future<void> uniqv_t; typedef std::future<void> uniqv_t;
typedef std::shared_future<int> shar_t; typedef std::shared_future<int> shar_t;
typedef std::shared_future<int&> sharr_t; typedef std::shared_future<int&> sharr_t;
...@@ -46,4 +46,6 @@ void test01() ...@@ -46,4 +46,6 @@ void test01()
typedef std::packaged_task<int> ptask_t; typedef std::packaged_task<int> ptask_t;
typedef std::packaged_task<int&> ptaskr_t; typedef std::packaged_task<int&> ptaskr_t;
typedef std::packaged_task<void> ptaskv_t; typedef std::packaged_task<void> ptaskv_t;
using std::async;
} }
// { dg-do compile { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" }
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <future>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
int f() { return 5; }
void test01()
{
bool test __attribute__((unused)) = true;
using std::packaged_task;
using std::allocator_arg;
using __gnu_test::uneq_allocator;
uneq_allocator<char> alloc(99);
packaged_task<int ()> p1(allocator_arg, alloc, f); // { dg-excess-errors "" }
VERIFY( static_cast<bool>(p1) );
p1();
VERIFY( p1.get_future().get() == 5 );
}
int main()
{
test01();
return 0;
}
...@@ -33,4 +33,4 @@ void test01() ...@@ -33,4 +33,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 32 } // { dg-error "used here" "" { target *-*-* } 32 }
// { dg-error "deleted function" "" { target *-*-* } 890 } // { dg-error "deleted function" "" { target *-*-* } 1209 }
...@@ -32,4 +32,4 @@ void test01() ...@@ -32,4 +32,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 31 } // { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 889 } // { dg-error "deleted function" "" { target *-*-* } 1208 }
...@@ -34,9 +34,10 @@ void test01() ...@@ -34,9 +34,10 @@ void test01()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::packaged_task<int&(int&)> p1(inc); std::packaged_task<int&(int&)> p1(inc);
std::unique_future<int&> f1 = p1.get_future(); std::future<int&> f1 = p1.get_future();
VERIFY( !f1.is_ready() ); VERIFY( f1.valid() );
VERIFY( !f1.wait_for(std::chrono::milliseconds(1)) );
int i1 = 0; int i1 = 0;
......
...@@ -42,8 +42,9 @@ void test01() ...@@ -42,8 +42,9 @@ void test01()
p1.get_future(); p1.get_future();
VERIFY( false ); VERIFY( false );
} }
catch (std::bad_function_call&) catch (const std::future_error& e)
{ {
VERIFY( e.code() == std::future_errc::future_already_retrieved );
test = true; test = true;
} }
......
...@@ -34,12 +34,12 @@ void test01() ...@@ -34,12 +34,12 @@ void test01()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::packaged_task<int()> p1(zero); std::packaged_task<int()> p1(zero);
std::unique_future<int> f1 = p1.get_future(); std::future<int> f1 = p1.get_future();
p1(); p1();
VERIFY( static_cast<bool>(p1) ); VERIFY( static_cast<bool>(p1) );
VERIFY( f1.has_value() ); VERIFY( f1.get() == 0 );
} }
int main() int main()
......
...@@ -41,8 +41,9 @@ void test01() ...@@ -41,8 +41,9 @@ void test01()
{ {
p1(4); p1(4);
} }
catch (std::bad_function_call&) catch (const std::future_error& e)
{ {
VERIFY( e.code() == std::future_errc::promise_already_satisfied );
test = true; test = true;
} }
......
...@@ -44,8 +44,9 @@ void test01() ...@@ -44,8 +44,9 @@ void test01()
{ {
p1(i1); p1(i1);
} }
catch (std::bad_function_call&) catch (const std::future_error& e)
{ {
VERIFY( e.code() == std::future_errc::promise_already_satisfied );
test = true; test = true;
} }
......
...@@ -31,14 +31,19 @@ void thrower() { throw 0; } ...@@ -31,14 +31,19 @@ void thrower() { throw 0; }
void test01() void test01()
{ {
bool test __attribute__((unused)) = true; bool test = false;
std::packaged_task<void()> p1(thrower); std::packaged_task<void()> p1(thrower);
std::unique_future<void> f1 = p1.get_future(); std::future<void> f1 = p1.get_future();
p1(); p1();
VERIFY( f1.has_exception() ); try {
f1.get();
} catch (int) {
test = true;
}
VERIFY( test );
} }
int main() int main()
......
...@@ -36,15 +36,13 @@ void test01() ...@@ -36,15 +36,13 @@ void test01()
using namespace std; using namespace std;
packaged_task<int()> p1(zero); packaged_task<int()> p1(zero);
unique_future<int> f1 = p1.get_future(); future<int> f1 = p1.get_future();
p1.reset(); p1.reset();
VERIFY( static_cast<bool>(p1) ); VERIFY( static_cast<bool>(p1) );
unique_future<int> f2 = p1.get_future(); future<int> f2 = p1.get_future();
VERIFY( !f2.is_ready() );
VERIFY( f1.has_exception() );
try try
{ {
f1.get(); f1.get();
......
...@@ -27,23 +27,24 @@ ...@@ -27,23 +27,24 @@
#include <future> #include <future>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
int zero() { return 0; } int iota() { static int i = 0; return i++; }
void test01() void test01()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::packaged_task<int()> p1(zero); std::packaged_task<int()> p1(iota);
std::unique_future<int> f1 = p1.get_future(); std::future<int> f1 = p1.get_future();
p1(); p1();
p1.reset(); p1.reset();
VERIFY( static_cast<bool>(p1) ); VERIFY( static_cast<bool>(p1) );
VERIFY( f1.has_value() ); VERIFY( f1.get() == 0 );
std::unique_future<int> f2 = p1.get_future(); std::future<int> f2 = p1.get_future();
VERIFY( !f2.is_ready() ); p1();
VERIFY( f2.get() == 1 );
} }
int main() int main()
......
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } } // { dg-do compile { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } } // { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } // { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } // { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" } // { dg-require-atomic-builtins "" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -23,48 +23,25 @@ ...@@ -23,48 +23,25 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
#include <future> #include <future>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#include <testsuite_allocator.h>
void test01() void test01()
{ {
bool test __attribute__((unused)) = true; using std::promise;
using std::allocator_arg;
std::promise<int> p1; using __gnu_test::uneq_allocator;
std::shared_future<int> f1(p1.get_future());
std::shared_future<int> f2(f1);
VERIFY( !f1.has_value() );
VERIFY( !f2.has_value() );
p1.set_value(1); uneq_allocator<char> alloc(99);
VERIFY( f1.has_value() ); promise<int> p1(allocator_arg, alloc); // { dg-excess-errors "" }
VERIFY( f2.has_value() ); p1.set_value(5);
} VERIFY( p1.get_future().get() == 5 );
void test02()
{
bool test __attribute__((unused)) = true;
std::promise<int> p1;
std::shared_future<int> f1(p1.get_future());
std::shared_future<int> f2(f1);
VERIFY( !f1.has_value() );
VERIFY( !f2.has_value() );
p1.set_exception(std::copy_exception(1));
VERIFY( !f1.has_value() );
VERIFY( !f2.has_value() );
} }
int main() int main()
{ {
test01(); test01();
test02();
return 0; return 0;
} }
...@@ -33,4 +33,4 @@ void test01() ...@@ -33,4 +33,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 32 } // { dg-error "used here" "" { target *-*-* } 32 }
// { dg-error "deleted function" "" { target *-*-* } 608 } // { dg-error "deleted function" "" { target *-*-* } 864 }
...@@ -32,4 +32,4 @@ void test01() ...@@ -32,4 +32,4 @@ void test01()
} }
// { dg-error "used here" "" { target *-*-* } 31 } // { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 592 } // { dg-error "deleted function" "" { target *-*-* } 848 }
...@@ -44,7 +44,7 @@ void test01() ...@@ -44,7 +44,7 @@ void test01()
} }
catch (std::future_error& e) catch (std::future_error& e)
{ {
VERIFY(e.code() == make_error_code(future_errc::future_already_retrieved)); VERIFY(e.code() == make_error_code(future_errc::no_state));
} }
} }
......
...@@ -45,7 +45,7 @@ void test01() ...@@ -45,7 +45,7 @@ void test01()
} }
catch (future_error& e) catch (future_error& e)
{ {
VERIFY(e.code() == make_error_code(future_errc::future_already_retrieved)); VERIFY(e.code() == make_error_code(future_errc::no_state));
} }
} }
......
...@@ -32,9 +32,9 @@ void test01() ...@@ -32,9 +32,9 @@ void test01()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int&> p1; std::promise<int&> p1;
std::unique_future<int&> f1 = p1.get_future(); std::future<int&> f1 = p1.get_future();
VERIFY( !f1.is_ready() ); VERIFY( f1.valid() );
int i1 = 0; int i1 = 0;
......
...@@ -29,17 +29,25 @@ ...@@ -29,17 +29,25 @@
void test01() void test01()
{ {
bool test __attribute__((unused)) = true; bool test = false;
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1 = p1.get_future(); std::future<int> f1 = p1.get_future();
VERIFY( !f1.is_ready() ); VERIFY( f1.valid() );
p1.set_exception(std::copy_exception(0)); p1.set_exception(std::copy_exception(0));
VERIFY( f1.has_exception() ); try
VERIFY( !f1.has_value() ); {
f1.get();
}
catch (int)
{
test = true;
}
VERIFY( test );
VERIFY( !f1.valid() );
} }
int main() int main()
......
...@@ -32,7 +32,7 @@ void test01() ...@@ -32,7 +32,7 @@ void test01()
bool test = false; bool test = false;
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1 = p1.get_future(); std::future<int> f1 = p1.get_future();
p1.set_exception(std::copy_exception(0)); p1.set_exception(std::copy_exception(0));
...@@ -66,7 +66,7 @@ void test02() ...@@ -66,7 +66,7 @@ void test02()
bool test = false; bool test = false;
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1 = p1.get_future(); std::future<int> f1 = p1.get_future();
p1.set_value(2); p1.set_value(2);
...@@ -82,8 +82,6 @@ void test02() ...@@ -82,8 +82,6 @@ void test02()
test = true; test = true;
} }
VERIFY( f1.has_value() );
VERIFY( !f1.has_exception() );
VERIFY( test ); VERIFY( test );
} }
......
...@@ -33,9 +33,9 @@ void test01() ...@@ -33,9 +33,9 @@ void test01()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1 = p1.get_future(); std::future<int> f1 = p1.get_future();
VERIFY( !f1.is_ready() ); VERIFY( f1.valid() );
p1.set_value(0); p1.set_value(0);
...@@ -50,15 +50,15 @@ void test02() ...@@ -50,15 +50,15 @@ void test02()
using __gnu_test::rvalstruct; using __gnu_test::rvalstruct;
std::promise<rvalstruct> p1; std::promise<rvalstruct> p1;
std::unique_future<rvalstruct> f1 = p1.get_future(); std::future<rvalstruct> f1 = p1.get_future();
VERIFY( !f1.is_ready() ); VERIFY( f1.valid() );
p1.set_value(rvalstruct(1)); p1.set_value(rvalstruct(1));
rvalstruct r1(f1.get()); rvalstruct r1(f1.get());
VERIFY( r1.valid ); VERIFY( !f1.valid() );
VERIFY( r1.val == 1 ); VERIFY( r1.val == 1 );
} }
...@@ -68,14 +68,15 @@ void test03() ...@@ -68,14 +68,15 @@ void test03()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int&> p1; std::promise<int&> p1;
std::unique_future<int&> f1 = p1.get_future(); std::future<int&> f1 = p1.get_future();
VERIFY( !f1.is_ready() ); VERIFY( f1.valid() );
int i1 = 0; int i1 = 0;
p1.set_value(i1); p1.set_value(i1);
int& i2 = f1.get(); int& i2 = f1.get();
VERIFY( !f1.valid() );
VERIFY( &i1 == &i2 ); VERIFY( &i1 == &i2 );
} }
...@@ -84,14 +85,14 @@ void test04() ...@@ -84,14 +85,14 @@ void test04()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<void> p1; std::promise<void> p1;
std::unique_future<void> f1 = p1.get_future(); std::future<void> f1 = p1.get_future();
VERIFY( !f1.is_ready() ); VERIFY( f1.valid() );
p1.set_value(); p1.set_value();
f1.get(); f1.get();
VERIFY( f1.is_ready() ); VERIFY( !f1.valid() );
} }
int main() int main()
......
...@@ -32,7 +32,7 @@ void test01() ...@@ -32,7 +32,7 @@ void test01()
bool test = false; bool test = false;
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1 = p1.get_future(); std::future<int> f1 = p1.get_future();
p1.set_value(1); p1.set_value(1);
...@@ -48,7 +48,7 @@ void test01() ...@@ -48,7 +48,7 @@ void test01()
test = true; test = true;
} }
VERIFY( f1.has_value() ); VERIFY( f1.wait_for(std::chrono::milliseconds(1)) );
VERIFY( f1.get() == 1 ); VERIFY( f1.get() == 1 );
VERIFY( test ); VERIFY( test );
} }
...@@ -58,7 +58,7 @@ void test02() ...@@ -58,7 +58,7 @@ void test02()
bool test = false; bool test = false;
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1 = p1.get_future(); std::future<int> f1 = p1.get_future();
p1.set_value(3); p1.set_value(3);
...@@ -74,8 +74,7 @@ void test02() ...@@ -74,8 +74,7 @@ void test02()
test = true; test = true;
} }
VERIFY( f1.has_value() ); VERIFY( f1.wait_for(std::chrono::milliseconds(1)) );
VERIFY( !f1.has_exception() );
VERIFY( f1.get() == 3 ); VERIFY( f1.get() == 3 );
VERIFY( test ); VERIFY( test );
} }
......
...@@ -41,33 +41,33 @@ struct tester ...@@ -41,33 +41,33 @@ struct tester
}; };
std::promise<tester> pglobal; std::promise<tester> pglobal;
std::unique_future<tester> fglobal = pglobal.get_future(); std::future<tester> fglobal = pglobal.get_future();
tester::tester(int) tester::tester(int)
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
VERIFY (!fglobal.is_ready()); VERIFY (!fglobal.wait_for(std::chrono::milliseconds(1)));
} }
tester::tester(const tester&) tester::tester(const tester&)
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
// if this copy happens while a mutex is locked next line could deadlock: // if this copy happens while a mutex is locked next line could deadlock:
VERIFY (!fglobal.is_ready()); VERIFY (!fglobal.wait_for(std::chrono::milliseconds(1)));
} }
tester& tester::operator=(const tester&) tester& tester::operator=(const tester&)
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
// if this copy happens while a mutex is locked next line could deadlock: // if this copy happens while a mutex is locked next line could deadlock:
VERIFY (!fglobal.is_ready()); VERIFY (!fglobal.wait_for(std::chrono::milliseconds(1)));
return *this; return *this;
} }
tester::~tester() tester::~tester()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
VERIFY (fglobal.is_ready()); VERIFY (fglobal.wait_for(std::chrono::milliseconds(1)));
} }
void test01() void test01()
...@@ -76,7 +76,7 @@ void test01() ...@@ -76,7 +76,7 @@ void test01()
pglobal.set_value( tester(1) ); pglobal.set_value( tester(1) );
VERIFY( fglobal.is_ready() ); VERIFY( fglobal.wait_for(std::chrono::milliseconds(1)) );
} }
int main() int main()
......
...@@ -35,8 +35,8 @@ void test01() ...@@ -35,8 +35,8 @@ void test01()
std::promise<int> p2; std::promise<int> p2;
p1.set_value(1); p1.set_value(1);
p1.swap(p2); p1.swap(p2);
VERIFY( !p1.get_future().is_ready() ); VERIFY( !p1.get_future().wait_for(std::chrono::milliseconds(1)) );
VERIFY( p2.get_future().is_ready() ); VERIFY( p2.get_future().wait_for(std::chrono::milliseconds(1)) );
} }
int main() int main()
......
// { dg-do compile }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" } // { dg-require-atomic-builtins "" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -23,16 +22,23 @@ ...@@ -23,16 +22,23 @@
#include <future> #include <future>
#include <testsuite_hooks.h>
extern std::shared_future<int>& get(); std::future<int> get() { return std::promise<int>().get_future(); }
void test01() void test01()
{ {
// assign // assign
std::shared_future<int>& p1 = get(); std::shared_future<int> p1;
std::shared_future<int>& p2 = get(); std::shared_future<int> p2 = get();
p1 = p2; p1 = p2;
VERIFY( p1.valid() );
VERIFY( p2.valid() );
}
int main()
{
test01();
return 0;
} }
// { dg-error "used here" "" { target *-*-* } 34 }
// { dg-error "deleted function" "" { target *-*-* } 493 }
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <future> #include <future>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
extern std::unique_future<int>&& get(); extern std::future<int>&& get();
void test01() void test01()
{ {
......
// { dg-do compile }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" } // { dg-require-atomic-builtins "" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -23,6 +22,7 @@ ...@@ -23,6 +22,7 @@
#include <future> #include <future>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h> #include <testsuite_tr1.h>
void test01() void test01()
...@@ -30,11 +30,18 @@ void test01() ...@@ -30,11 +30,18 @@ void test01()
using std::shared_future; using std::shared_future;
using namespace __gnu_test; using namespace __gnu_test;
shared_future<int> p1; // { dg-error "22: error: no match" } bool __attribute__((unused)) test = true;
shared_future<int&> p2; // { dg-error "23: error: no match" }
shared_future<void> p3; // { dg-error "23: error: no match" } shared_future<int> p1;
shared_future<ClassType> p4; // { dg-error "28: error: no match" } VERIFY( !p1.valid() );
shared_future<AbstractClass&> p5; // { dg-error "33: error: no match" } shared_future<int&> p2;
VERIFY( !p2.valid() );
shared_future<void> p3;
VERIFY( !p3.valid() );
shared_future<ClassType> p4;
VERIFY( !p4.valid() );
shared_future<AbstractClass&> p5;
VERIFY( !p5.valid() );
} }
int main() int main()
...@@ -42,4 +49,3 @@ int main() ...@@ -42,4 +49,3 @@ int main()
test01(); test01();
return 0; return 0;
} }
// { dg-excess-errors "note" }
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
void test01() void test01()
{ {
// construct from rvalue unique_future // construct from rvalue future
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1(p1.get_future()); std::future<int> f1(p1.get_future());
std::shared_future<int> f2(std::move(f1)); std::shared_future<int> f2(std::move(f1));
} }
......
// { dg-do compile }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" } // { dg-require-atomic-builtins "" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -23,18 +22,18 @@ ...@@ -23,18 +22,18 @@
#include <future> #include <future>
#include <testsuite_tr1.h> #include <testsuite_hooks.h>
std::future<int> get() { return std::promise<int>().get_future(); }
void test01() void test01()
{ {
using std::unique_future; // assign
using namespace __gnu_test; std::shared_future<int> p1;
std::shared_future<int> p2 = get();
unique_future<int> p1; // { dg-error "22: error: no match" } p1 = std::move(p2);
unique_future<int&> p2; // { dg-error "23: error: no match" } VERIFY( p1.valid() );
unique_future<void> p3; // { dg-error "23: error: no match" } VERIFY( !p2.valid() );
unique_future<ClassType> p4; // { dg-error "28: error: no match" }
unique_future<AbstractClass&> p5; // { dg-error "33: error: no match" }
} }
int main() int main()
...@@ -42,4 +41,3 @@ int main() ...@@ -42,4 +41,3 @@ int main()
test01(); test01();
return 0; return 0;
} }
// { dg-excess-errors "note" }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" } // { dg-require-atomic-builtins "" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -31,17 +31,27 @@ void test01() ...@@ -31,17 +31,27 @@ void test01()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::shared_future<int> f0;
VERIFY( !f0.valid() );
std::promise<int> p1; std::promise<int> p1;
std::shared_future<int> f1(p1.get_future()); std::shared_future<int> f1(p1.get_future());
std::shared_future<int> f2(f1); std::shared_future<int> f2(f1);
VERIFY( !f1.is_ready() ); VERIFY( f1.valid() );
VERIFY( !f2.is_ready() ); VERIFY( f2.valid() );
p1.set_value(1); p1.set_value(1);
VERIFY( f1.is_ready() ); VERIFY( f1.valid() );
VERIFY( f2.is_ready() ); VERIFY( f2.valid() );
f1 = std::move(f0);
VERIFY( !f0.valid() );
VERIFY( !f1.valid() );
VERIFY( f2.valid() );
} }
int main() int main()
......
...@@ -24,15 +24,15 @@ ...@@ -24,15 +24,15 @@
#include <future> #include <future>
extern std::unique_future<int>& get(); extern std::future<int>& get();
void test01() void test01()
{ {
// assign // assign
std::unique_future<int>& p1 = get(); std::future<int>& p1 = get();
std::unique_future<int>& p2 = get(); std::future<int>& p2 = get();
p1 = p2; p1 = p2;
} }
// { dg-error "used here" "" { target *-*-* } 34 } // { dg-error "used here" "" { target *-*-* } 34 }
// { dg-error "deleted function" "" { target *-*-* } 419 } // { dg-error "deleted function" "" { target *-*-* } 578 }
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
#include <future> #include <future>
extern std::unique_future<int>& get(); extern std::future<int>& get();
void test01() void test01()
{ {
// copy // copy
std::unique_future<int>& p1 = get(); std::future<int>& p1 = get();
std::unique_future<int> p2(p1); std::future<int> p2(p1);
} }
// { dg-error "used here" "" { target *-*-* } 33 } // { dg-error "used here" "" { target *-*-* } 33 }
// { dg-error "deleted function" "" { target *-*-* } 418 } // { dg-error "deleted function" "" { target *-*-* } 577 }
// { dg-options "-std=gnu++0x" }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" }
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <future>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
void test01()
{
using std::future;
using namespace __gnu_test;
bool __attribute__((unused)) test = true;
future<int> p1;
VERIFY( !p1.valid() );
future<int&> p2;
VERIFY( !p2.valid() );
future<void> p3;
VERIFY( !p3.valid() );
future<ClassType> p4;
VERIFY( !p4.valid() );
future<AbstractClass&> p5;
VERIFY( !p5.valid() );
}
int main()
{
test01();
return 0;
}
...@@ -30,8 +30,8 @@ void test01() ...@@ -30,8 +30,8 @@ void test01()
{ {
// move // move
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1(p1.get_future()); std::future<int> f1(p1.get_future());
std::unique_future<int> f2(std::move(f1)); std::future<int> f2(std::move(f1));
} }
int main() int main()
......
// { dg-options "-std=gnu++0x" }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" }
// Copyright (C) 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <future>
#include <testsuite_hooks.h>
std::future<int> get() { return std::promise<int>().get_future(); }
void test01()
{
// assign
std::future<int> p1;
std::future<int> p2 = get();
p1 = std::move(p2);
VERIFY( p1.valid() );
VERIFY( !p2.valid() );
}
int main()
{
test01();
return 0;
}
...@@ -34,10 +34,11 @@ void test01() ...@@ -34,10 +34,11 @@ void test01()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1(p1.get_future()); std::future<int> f1(p1.get_future());
p1.set_value(value); p1.set_value(value);
VERIFY( f1.get() == value ); VERIFY( f1.get() == value );
VERIFY( !f1.valid() );
} }
void test02() void test02()
...@@ -45,19 +46,21 @@ void test02() ...@@ -45,19 +46,21 @@ void test02()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int&> p1; std::promise<int&> p1;
std::unique_future<int&> f1(p1.get_future()); std::future<int&> f1(p1.get_future());
p1.set_value(value); p1.set_value(value);
VERIFY( &f1.get() == &value ); VERIFY( &f1.get() == &value );
VERIFY( !f1.valid() );
} }
void test03() void test03()
{ {
std::promise<void> p1; std::promise<void> p1;
std::unique_future<void> f1(p1.get_future()); std::future<void> f1(p1.get_future());
p1.set_value(); p1.set_value();
f1.get(); f1.get();
VERIFY( !f1.valid() );
} }
int main() int main()
......
...@@ -35,7 +35,7 @@ void test01() ...@@ -35,7 +35,7 @@ void test01()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1(p1.get_future()); std::future<int> f1(p1.get_future());
p1.set_exception(std::copy_exception(value)); p1.set_exception(std::copy_exception(value));
try try
...@@ -47,6 +47,7 @@ void test01() ...@@ -47,6 +47,7 @@ void test01()
{ {
VERIFY( e == value ); VERIFY( e == value );
} }
VERIFY( !f1.valid() );
} }
void test02() void test02()
...@@ -54,7 +55,7 @@ void test02() ...@@ -54,7 +55,7 @@ void test02()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int&> p1; std::promise<int&> p1;
std::unique_future<int&> f1(p1.get_future()); std::future<int&> f1(p1.get_future());
p1.set_exception(std::copy_exception(value)); p1.set_exception(std::copy_exception(value));
try try
...@@ -66,6 +67,7 @@ void test02() ...@@ -66,6 +67,7 @@ void test02()
{ {
VERIFY( e == value ); VERIFY( e == value );
} }
VERIFY( !f1.valid() );
} }
void test03() void test03()
...@@ -73,7 +75,7 @@ void test03() ...@@ -73,7 +75,7 @@ void test03()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<void> p1; std::promise<void> p1;
std::unique_future<void> f1(p1.get_future()); std::future<void> f1(p1.get_future());
p1.set_exception(std::copy_exception(value)); p1.set_exception(std::copy_exception(value));
try try
...@@ -85,6 +87,7 @@ void test03() ...@@ -85,6 +87,7 @@ void test03()
{ {
VERIFY( e == value ); VERIFY( e == value );
} }
VERIFY( !f1.valid() );
} }
int main() int main()
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" } // { dg-require-atomic-builtins "" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -31,14 +31,22 @@ void test01() ...@@ -31,14 +31,22 @@ void test01()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::future<int> f0;
VERIFY( !f0.valid() );
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1(p1.get_future()); std::future<int> f1(p1.get_future());
VERIFY( !f1.is_ready() ); VERIFY( f1.valid() );
p1.set_value(1); p1.set_value(1);
VERIFY( f1.is_ready() ); VERIFY( f1.valid() );
f1 = std::move(f0);
VERIFY( !f1.valid() );
VERIFY( !f0.valid() );
} }
int main() int main()
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
void wait(std::unique_future<void>& f) void wait(std::future<void>& f)
{ {
f.wait(); f.wait();
} }
...@@ -39,7 +39,7 @@ void wait(std::unique_future<void>& f) ...@@ -39,7 +39,7 @@ void wait(std::unique_future<void>& f)
void test01() void test01()
{ {
std::promise<void> p1; std::promise<void> p1;
std::unique_future<void> f1(p1.get_future()); std::future<void> f1(p1.get_future());
std::thread t1(wait, std::ref(f1)); std::thread t1(wait, std::ref(f1));
......
...@@ -33,7 +33,7 @@ void test01() ...@@ -33,7 +33,7 @@ void test01()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1(p1.get_future()); std::future<int> f1(p1.get_future());
std::chrono::milliseconds delay(100); std::chrono::milliseconds delay(100);
......
...@@ -38,7 +38,7 @@ void test01() ...@@ -38,7 +38,7 @@ void test01()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int> p1; std::promise<int> p1;
std::unique_future<int> f1(p1.get_future()); std::future<int> f1(p1.get_future());
auto when = make_time(10); auto when = make_time(10);
VERIFY( !f1.wait_until(when) ); VERIFY( !f1.wait_until(when) );
......
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
#include <testsuite_tr1.h> #include <testsuite_tr1.h>
using namespace __gnu_test; using namespace __gnu_test;
using std::unique_future; using std::future;
template class unique_future<int>; template class future<int>;
template class unique_future<int&>; template class future<int&>;
template class unique_future<void>; template class future<void>;
template class unique_future<ClassType>; template class future<ClassType>;
template class unique_future<ClassType&>; template class future<ClassType&>;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment