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
This commit is contained in:
parent
4227d4a1a5
commit
b3eed6fe78
@ -1,3 +1,64 @@
|
||||
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>
|
||||
Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -103,7 +103,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
|
||||
void
|
||||
__throw_future_error(int __i)
|
||||
{ throw future_error(future_errc(__i)); }
|
||||
{ throw future_error(make_error_code(future_errc(__i))); }
|
||||
|
||||
void
|
||||
__throw_bad_function_call()
|
||||
|
@ -6,7 +6,7 @@
|
||||
// { dg-require-gthreads "" }
|
||||
// { 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
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -27,38 +27,32 @@
|
||||
#include <future>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
struct sum {
|
||||
typedef int result_type;
|
||||
int operator()(int i, int& j, const int& k) { return i + j + k; }
|
||||
};
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1(p1.get_future());
|
||||
using namespace std;
|
||||
|
||||
VERIFY( !f1.has_exception() );
|
||||
int a = 1;
|
||||
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_exception(std::copy_exception(1));
|
||||
|
||||
VERIFY( f1.has_exception() );
|
||||
}
|
||||
|
||||
void test02()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1(p1.get_future());
|
||||
|
||||
VERIFY( !f1.has_exception() );
|
||||
|
||||
p1.set_value(1);
|
||||
|
||||
VERIFY( !f1.has_exception() );
|
||||
VERIFY( f1.valid() );
|
||||
VERIFY( f2.valid() );
|
||||
int r1 = f1.get();
|
||||
int r2 = f2.get();
|
||||
VERIFY( r1 == r2 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
|
||||
return 0;
|
||||
}
|
57
libstdc++-v3/testsuite/30_threads/async/async.cc
Normal file
57
libstdc++-v3/testsuite/30_threads/async/async.cc
Normal file
@ -0,0 +1,57 @@
|
||||
// { dg-do run { 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>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct work {
|
||||
typedef void result_type;
|
||||
void operator()(mutex& m, condition_variable& cv)
|
||||
{
|
||||
unique_lock<mutex> l(m);
|
||||
cv.notify_one();
|
||||
}
|
||||
};
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
mutex m;
|
||||
condition_variable cv;
|
||||
unique_lock<mutex> l(m);
|
||||
future<void> f1 = async(launch::async, work(), ref(m), ref(cv));
|
||||
cv.wait(l);
|
||||
f1.get();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
// { dg-require-gthreads "" }
|
||||
// { 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
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -27,18 +27,24 @@
|
||||
#include <future>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
struct sum {
|
||||
typedef int result_type;
|
||||
int operator()(int i, int& j, const int& k) { return i + j + k; }
|
||||
};
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1(p1.get_future());
|
||||
using namespace std;
|
||||
|
||||
VERIFY( !f1.is_ready() );
|
||||
int a = 1;
|
||||
int b = 10;
|
||||
int c = 100;
|
||||
future<int> f1 = async(launch::sync, sum(), a, ref(b), cref(c));
|
||||
|
||||
p1.set_value(1);
|
||||
|
||||
VERIFY( f1.is_ready() );
|
||||
VERIFY( f1.valid() );
|
||||
VERIFY( f1.get() == 111 );
|
||||
}
|
||||
|
||||
int main()
|
@ -31,9 +31,9 @@ void test01()
|
||||
|
||||
typedef std::future_error error_t;
|
||||
|
||||
typedef std::unique_future<int> uniq_t;
|
||||
typedef std::unique_future<int&> uniqr_t;
|
||||
typedef std::unique_future<void> uniqv_t;
|
||||
typedef std::future<int> uniq_t;
|
||||
typedef std::future<int&> uniqr_t;
|
||||
typedef std::future<void> uniqv_t;
|
||||
|
||||
typedef std::shared_future<int> shar_t;
|
||||
typedef std::shared_future<int&> sharr_t;
|
||||
@ -46,4 +46,6 @@ void test01()
|
||||
typedef std::packaged_task<int> ptask_t;
|
||||
typedef std::packaged_task<int&> ptaskr_t;
|
||||
typedef std::packaged_task<void> ptaskv_t;
|
||||
|
||||
using std::async;
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
// { 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()
|
||||
}
|
||||
|
||||
// { dg-error "used here" "" { target *-*-* } 32 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 890 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 1209 }
|
||||
|
@ -32,4 +32,4 @@ void test01()
|
||||
}
|
||||
|
||||
// { dg-error "used here" "" { target *-*-* } 31 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 889 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 1208 }
|
||||
|
@ -34,9 +34,10 @@ void test01()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -42,8 +42,9 @@ void test01()
|
||||
p1.get_future();
|
||||
VERIFY( false );
|
||||
}
|
||||
catch (std::bad_function_call&)
|
||||
catch (const std::future_error& e)
|
||||
{
|
||||
VERIFY( e.code() == std::future_errc::future_already_retrieved );
|
||||
test = true;
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,12 @@ void test01()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::packaged_task<int()> p1(zero);
|
||||
std::unique_future<int> f1 = p1.get_future();
|
||||
std::future<int> f1 = p1.get_future();
|
||||
|
||||
p1();
|
||||
|
||||
VERIFY( static_cast<bool>(p1) );
|
||||
VERIFY( f1.has_value() );
|
||||
VERIFY( f1.get() == 0 );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -41,8 +41,9 @@ void test01()
|
||||
{
|
||||
p1(4);
|
||||
}
|
||||
catch (std::bad_function_call&)
|
||||
catch (const std::future_error& e)
|
||||
{
|
||||
VERIFY( e.code() == std::future_errc::promise_already_satisfied );
|
||||
test = true;
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,9 @@ void test01()
|
||||
{
|
||||
p1(i1);
|
||||
}
|
||||
catch (std::bad_function_call&)
|
||||
catch (const std::future_error& e)
|
||||
{
|
||||
VERIFY( e.code() == std::future_errc::promise_already_satisfied );
|
||||
test = true;
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,19 @@ void thrower() { throw 0; }
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
bool test = false;
|
||||
|
||||
std::packaged_task<void()> p1(thrower);
|
||||
std::unique_future<void> f1 = p1.get_future();
|
||||
std::future<void> f1 = p1.get_future();
|
||||
|
||||
p1();
|
||||
|
||||
VERIFY( f1.has_exception() );
|
||||
try {
|
||||
f1.get();
|
||||
} catch (int) {
|
||||
test = true;
|
||||
}
|
||||
VERIFY( test );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -36,15 +36,13 @@ void test01()
|
||||
using namespace std;
|
||||
|
||||
packaged_task<int()> p1(zero);
|
||||
unique_future<int> f1 = p1.get_future();
|
||||
future<int> f1 = p1.get_future();
|
||||
|
||||
p1.reset();
|
||||
VERIFY( static_cast<bool>(p1) );
|
||||
|
||||
unique_future<int> f2 = p1.get_future();
|
||||
VERIFY( !f2.is_ready() );
|
||||
future<int> f2 = p1.get_future();
|
||||
|
||||
VERIFY( f1.has_exception() );
|
||||
try
|
||||
{
|
||||
f1.get();
|
||||
|
@ -27,23 +27,24 @@
|
||||
#include <future>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
int zero() { return 0; }
|
||||
int iota() { static int i = 0; return i++; }
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::packaged_task<int()> p1(zero);
|
||||
std::unique_future<int> f1 = p1.get_future();
|
||||
std::packaged_task<int()> p1(iota);
|
||||
std::future<int> f1 = p1.get_future();
|
||||
|
||||
p1();
|
||||
p1.reset();
|
||||
|
||||
VERIFY( static_cast<bool>(p1) );
|
||||
VERIFY( f1.has_value() );
|
||||
VERIFY( f1.get() == 0 );
|
||||
|
||||
std::unique_future<int> f2 = p1.get_future();
|
||||
VERIFY( !f2.is_ready() );
|
||||
std::future<int> f2 = p1.get_future();
|
||||
p1();
|
||||
VERIFY( f2.get() == 1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
47
libstdc++-v3/testsuite/30_threads/promise/cons/alloc.cc
Normal file
47
libstdc++-v3/testsuite/30_threads/promise/cons/alloc.cc
Normal file
@ -0,0 +1,47 @@
|
||||
// { 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>
|
||||
|
||||
void test01()
|
||||
{
|
||||
using std::promise;
|
||||
using std::allocator_arg;
|
||||
using __gnu_test::uneq_allocator;
|
||||
|
||||
uneq_allocator<char> alloc(99);
|
||||
|
||||
promise<int> p1(allocator_arg, alloc); // { dg-excess-errors "" }
|
||||
p1.set_value(5);
|
||||
VERIFY( p1.get_future().get() == 5 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
@ -33,4 +33,4 @@ void test01()
|
||||
}
|
||||
|
||||
// { dg-error "used here" "" { target *-*-* } 32 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 608 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 864 }
|
||||
|
@ -32,4 +32,4 @@ void test01()
|
||||
}
|
||||
|
||||
// { dg-error "used here" "" { target *-*-* } 31 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 592 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 848 }
|
||||
|
@ -44,7 +44,7 @@ void test01()
|
||||
}
|
||||
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()
|
||||
}
|
||||
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()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -29,17 +29,25 @@
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
bool test = false;
|
||||
|
||||
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));
|
||||
|
||||
VERIFY( f1.has_exception() );
|
||||
VERIFY( !f1.has_value() );
|
||||
try
|
||||
{
|
||||
f1.get();
|
||||
}
|
||||
catch (int)
|
||||
{
|
||||
test = true;
|
||||
}
|
||||
VERIFY( test );
|
||||
VERIFY( !f1.valid() );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -32,7 +32,7 @@ void test01()
|
||||
bool test = false;
|
||||
|
||||
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));
|
||||
|
||||
@ -66,7 +66,7 @@ void test02()
|
||||
bool test = false;
|
||||
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1 = p1.get_future();
|
||||
std::future<int> f1 = p1.get_future();
|
||||
|
||||
p1.set_value(2);
|
||||
|
||||
@ -82,8 +82,6 @@ void test02()
|
||||
test = true;
|
||||
}
|
||||
|
||||
VERIFY( f1.has_value() );
|
||||
VERIFY( !f1.has_exception() );
|
||||
VERIFY( test );
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,9 @@ void test01()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
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);
|
||||
|
||||
@ -50,15 +50,15 @@ void test02()
|
||||
using __gnu_test::rvalstruct;
|
||||
|
||||
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));
|
||||
|
||||
rvalstruct r1(f1.get());
|
||||
|
||||
VERIFY( r1.valid );
|
||||
VERIFY( !f1.valid() );
|
||||
VERIFY( r1.val == 1 );
|
||||
}
|
||||
|
||||
@ -68,14 +68,15 @@ void test03()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
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;
|
||||
p1.set_value(i1);
|
||||
int& i2 = f1.get();
|
||||
|
||||
VERIFY( !f1.valid() );
|
||||
VERIFY( &i1 == &i2 );
|
||||
}
|
||||
|
||||
@ -84,14 +85,14 @@ void test04()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
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();
|
||||
f1.get();
|
||||
|
||||
VERIFY( f1.is_ready() );
|
||||
VERIFY( !f1.valid() );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -32,7 +32,7 @@ void test01()
|
||||
bool test = false;
|
||||
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1 = p1.get_future();
|
||||
std::future<int> f1 = p1.get_future();
|
||||
|
||||
p1.set_value(1);
|
||||
|
||||
@ -48,7 +48,7 @@ void test01()
|
||||
test = true;
|
||||
}
|
||||
|
||||
VERIFY( f1.has_value() );
|
||||
VERIFY( f1.wait_for(std::chrono::milliseconds(1)) );
|
||||
VERIFY( f1.get() == 1 );
|
||||
VERIFY( test );
|
||||
}
|
||||
@ -58,7 +58,7 @@ void test02()
|
||||
bool test = false;
|
||||
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1 = p1.get_future();
|
||||
std::future<int> f1 = p1.get_future();
|
||||
|
||||
p1.set_value(3);
|
||||
|
||||
@ -74,8 +74,7 @@ void test02()
|
||||
test = true;
|
||||
}
|
||||
|
||||
VERIFY( f1.has_value() );
|
||||
VERIFY( !f1.has_exception() );
|
||||
VERIFY( f1.wait_for(std::chrono::milliseconds(1)) );
|
||||
VERIFY( f1.get() == 3 );
|
||||
VERIFY( test );
|
||||
}
|
||||
|
@ -41,33 +41,33 @@ struct tester
|
||||
};
|
||||
|
||||
std::promise<tester> pglobal;
|
||||
std::unique_future<tester> fglobal = pglobal.get_future();
|
||||
std::future<tester> fglobal = pglobal.get_future();
|
||||
|
||||
tester::tester(int)
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
VERIFY (!fglobal.is_ready());
|
||||
VERIFY (!fglobal.wait_for(std::chrono::milliseconds(1)));
|
||||
}
|
||||
|
||||
tester::tester(const tester&)
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
// 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&)
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
// 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;
|
||||
}
|
||||
|
||||
tester::~tester()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
VERIFY (fglobal.is_ready());
|
||||
VERIFY (fglobal.wait_for(std::chrono::milliseconds(1)));
|
||||
}
|
||||
|
||||
void test01()
|
||||
@ -76,7 +76,7 @@ void test01()
|
||||
|
||||
pglobal.set_value( tester(1) );
|
||||
|
||||
VERIFY( fglobal.is_ready() );
|
||||
VERIFY( fglobal.wait_for(std::chrono::milliseconds(1)) );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -35,8 +35,8 @@ void test01()
|
||||
std::promise<int> p2;
|
||||
p1.set_value(1);
|
||||
p1.swap(p2);
|
||||
VERIFY( !p1.get_future().is_ready() );
|
||||
VERIFY( p2.get_future().is_ready() );
|
||||
VERIFY( !p1.get_future().wait_for(std::chrono::milliseconds(1)) );
|
||||
VERIFY( p2.get_future().wait_for(std::chrono::milliseconds(1)) );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -1,10 +1,9 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
// { dg-require-gthreads "" }
|
||||
// { 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
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -23,16 +22,23 @@
|
||||
|
||||
|
||||
#include <future>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
extern std::shared_future<int>& get();
|
||||
std::future<int> get() { return std::promise<int>().get_future(); }
|
||||
|
||||
void test01()
|
||||
{
|
||||
// assign
|
||||
std::shared_future<int>& p1 = get();
|
||||
std::shared_future<int>& p2 = get();
|
||||
std::shared_future<int> p1;
|
||||
std::shared_future<int> p2 = get();
|
||||
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 @@
|
||||
#include <future>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
extern std::unique_future<int>&& get();
|
||||
extern std::future<int>&& get();
|
||||
|
||||
void test01()
|
||||
{
|
||||
|
@ -1,10 +1,9 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
// { dg-require-gthreads "" }
|
||||
// { 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
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -23,6 +22,7 @@
|
||||
|
||||
|
||||
#include <future>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_tr1.h>
|
||||
|
||||
void test01()
|
||||
@ -30,11 +30,18 @@ void test01()
|
||||
using std::shared_future;
|
||||
using namespace __gnu_test;
|
||||
|
||||
shared_future<int> p1; // { dg-error "22: error: no match" }
|
||||
shared_future<int&> p2; // { dg-error "23: error: no match" }
|
||||
shared_future<void> p3; // { dg-error "23: error: no match" }
|
||||
shared_future<ClassType> p4; // { dg-error "28: error: no match" }
|
||||
shared_future<AbstractClass&> p5; // { dg-error "33: error: no match" }
|
||||
bool __attribute__((unused)) test = true;
|
||||
|
||||
shared_future<int> p1;
|
||||
VERIFY( !p1.valid() );
|
||||
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()
|
||||
@ -42,4 +49,3 @@ int main()
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
// { dg-excess-errors "note" }
|
@ -28,9 +28,9 @@
|
||||
|
||||
void test01()
|
||||
{
|
||||
// construct from rvalue unique_future
|
||||
// construct from rvalue future
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
// { 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::shared_future<int> p1;
|
||||
std::shared_future<int> p2 = get();
|
||||
p1 = std::move(p2);
|
||||
VERIFY( p1.valid() );
|
||||
VERIFY( !p2.valid() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// { dg-do run { 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) 2009 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>
|
||||
|
||||
void test01()
|
||||
{
|
||||
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_exception() );
|
||||
VERIFY( !f2.has_exception() );
|
||||
|
||||
p1.set_exception(std::copy_exception(1));
|
||||
|
||||
VERIFY( f1.has_exception() );
|
||||
VERIFY( f2.has_exception() );
|
||||
}
|
||||
|
||||
void test02()
|
||||
{
|
||||
std::promise<int> p1;
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::shared_future<int> f1(p1.get_future());
|
||||
std::shared_future<int> f2(f1);
|
||||
|
||||
VERIFY( !f1.has_exception() );
|
||||
VERIFY( !f2.has_exception() );
|
||||
|
||||
p1.set_value(1);
|
||||
|
||||
VERIFY( !f1.has_exception() );
|
||||
VERIFY( !f2.has_exception() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// { dg-do run { 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) 2009 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>
|
||||
|
||||
void test01()
|
||||
{
|
||||
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_value(1);
|
||||
|
||||
VERIFY( f1.has_value() );
|
||||
VERIFY( f2.has_value() );
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
|
||||
return 0;
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
// { dg-require-gthreads "" }
|
||||
// { 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
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -31,35 +31,31 @@ void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1(p1.get_future());
|
||||
std::shared_future<int> f0;
|
||||
|
||||
VERIFY( !f1.has_value() );
|
||||
VERIFY( !f0.valid() );
|
||||
|
||||
std::promise<int> p1;
|
||||
std::shared_future<int> f1(p1.get_future());
|
||||
std::shared_future<int> f2(f1);
|
||||
|
||||
VERIFY( f1.valid() );
|
||||
VERIFY( f2.valid() );
|
||||
|
||||
p1.set_value(1);
|
||||
|
||||
VERIFY( f1.has_value() );
|
||||
}
|
||||
VERIFY( f1.valid() );
|
||||
VERIFY( f2.valid() );
|
||||
|
||||
void test02()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
f1 = std::move(f0);
|
||||
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1(p1.get_future());
|
||||
|
||||
VERIFY( !f1.has_value() );
|
||||
|
||||
p1.set_exception(std::copy_exception(1));
|
||||
|
||||
VERIFY( !f1.has_value() );
|
||||
VERIFY( !f0.valid() );
|
||||
VERIFY( !f1.valid() );
|
||||
VERIFY( f2.valid() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -24,15 +24,15 @@
|
||||
|
||||
#include <future>
|
||||
|
||||
extern std::unique_future<int>& get();
|
||||
extern std::future<int>& get();
|
||||
|
||||
void test01()
|
||||
{
|
||||
// assign
|
||||
std::unique_future<int>& p1 = get();
|
||||
std::unique_future<int>& p2 = get();
|
||||
std::future<int>& p1 = get();
|
||||
std::future<int>& p2 = get();
|
||||
p1 = p2;
|
||||
}
|
||||
|
||||
// { dg-error "used here" "" { target *-*-* } 34 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 419 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 578 }
|
||||
|
@ -24,14 +24,14 @@
|
||||
|
||||
#include <future>
|
||||
|
||||
extern std::unique_future<int>& get();
|
||||
extern std::future<int>& get();
|
||||
|
||||
void test01()
|
||||
{
|
||||
// copy
|
||||
std::unique_future<int>& p1 = get();
|
||||
std::unique_future<int> p2(p1);
|
||||
std::future<int>& p1 = get();
|
||||
std::future<int> p2(p1);
|
||||
}
|
||||
|
||||
// { dg-error "used here" "" { target *-*-* } 33 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 418 }
|
||||
// { dg-error "deleted function" "" { target *-*-* } 577 }
|
||||
|
@ -1,10 +1,9 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-cstdint "" }
|
||||
// { dg-require-gthreads "" }
|
||||
// { 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
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -23,18 +22,26 @@
|
||||
|
||||
|
||||
#include <future>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_tr1.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
using std::unique_future;
|
||||
using std::future;
|
||||
using namespace __gnu_test;
|
||||
|
||||
unique_future<int> p1; // { dg-error "22: error: no match" }
|
||||
unique_future<int&> p2; // { dg-error "23: error: no match" }
|
||||
unique_future<void> p3; // { dg-error "23: error: no match" }
|
||||
unique_future<ClassType> p4; // { dg-error "28: error: no match" }
|
||||
unique_future<AbstractClass&> p5; // { dg-error "33: error: no match" }
|
||||
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()
|
||||
@ -42,4 +49,3 @@ int main()
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
// { dg-excess-errors "note" }
|
@ -30,8 +30,8 @@ void test01()
|
||||
{
|
||||
// move
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1(p1.get_future());
|
||||
std::unique_future<int> f2(std::move(f1));
|
||||
std::future<int> f1(p1.get_future());
|
||||
std::future<int> f2(std::move(f1));
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -0,0 +1,43 @@
|
||||
// { 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()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1(p1.get_future());
|
||||
std::future<int> f1(p1.get_future());
|
||||
|
||||
p1.set_value(value);
|
||||
VERIFY( f1.get() == value );
|
||||
VERIFY( !f1.valid() );
|
||||
}
|
||||
|
||||
void test02()
|
||||
@ -45,19 +46,21 @@ void test02()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::promise<int&> p1;
|
||||
std::unique_future<int&> f1(p1.get_future());
|
||||
std::future<int&> f1(p1.get_future());
|
||||
|
||||
p1.set_value(value);
|
||||
VERIFY( &f1.get() == &value );
|
||||
VERIFY( !f1.valid() );
|
||||
}
|
||||
|
||||
void test03()
|
||||
{
|
||||
std::promise<void> p1;
|
||||
std::unique_future<void> f1(p1.get_future());
|
||||
std::future<void> f1(p1.get_future());
|
||||
|
||||
p1.set_value();
|
||||
f1.get();
|
||||
VERIFY( !f1.valid() );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -35,7 +35,7 @@ void test01()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
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));
|
||||
try
|
||||
@ -47,6 +47,7 @@ void test01()
|
||||
{
|
||||
VERIFY( e == value );
|
||||
}
|
||||
VERIFY( !f1.valid() );
|
||||
}
|
||||
|
||||
void test02()
|
||||
@ -54,7 +55,7 @@ void test02()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
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));
|
||||
try
|
||||
@ -66,6 +67,7 @@ void test02()
|
||||
{
|
||||
VERIFY( e == value );
|
||||
}
|
||||
VERIFY( !f1.valid() );
|
||||
}
|
||||
|
||||
void test03()
|
||||
@ -73,7 +75,7 @@ void test03()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
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));
|
||||
try
|
||||
@ -85,6 +87,7 @@ void test03()
|
||||
{
|
||||
VERIFY( e == value );
|
||||
}
|
||||
VERIFY( !f1.valid() );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -6,7 +6,7 @@
|
||||
// { dg-require-gthreads "" }
|
||||
// { 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
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -31,17 +31,22 @@ void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::promise<int> p1;
|
||||
std::shared_future<int> f1(p1.get_future());
|
||||
std::shared_future<int> f2(f1);
|
||||
std::future<int> f0;
|
||||
VERIFY( !f0.valid() );
|
||||
|
||||
VERIFY( !f1.is_ready() );
|
||||
VERIFY( !f2.is_ready() );
|
||||
std::promise<int> p1;
|
||||
std::future<int> f1(p1.get_future());
|
||||
|
||||
VERIFY( f1.valid() );
|
||||
|
||||
p1.set_value(1);
|
||||
|
||||
VERIFY( f1.is_ready() );
|
||||
VERIFY( f2.is_ready() );
|
||||
VERIFY( f1.valid() );
|
||||
|
||||
f1 = std::move(f0);
|
||||
|
||||
VERIFY( !f1.valid() );
|
||||
VERIFY( !f0.valid() );
|
||||
}
|
||||
|
||||
int main()
|
@ -31,7 +31,7 @@
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
|
||||
void wait(std::unique_future<void>& f)
|
||||
void wait(std::future<void>& f)
|
||||
{
|
||||
f.wait();
|
||||
}
|
||||
@ -39,7 +39,7 @@ void wait(std::unique_future<void>& f)
|
||||
void test01()
|
||||
{
|
||||
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));
|
||||
|
||||
|
@ -33,7 +33,7 @@ void test01()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1(p1.get_future());
|
||||
std::future<int> f1(p1.get_future());
|
||||
|
||||
std::chrono::milliseconds delay(100);
|
||||
|
||||
|
@ -38,7 +38,7 @@ void test01()
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::promise<int> p1;
|
||||
std::unique_future<int> f1(p1.get_future());
|
||||
std::future<int> f1(p1.get_future());
|
||||
|
||||
auto when = make_time(10);
|
||||
VERIFY( !f1.wait_until(when) );
|
||||
|
@ -26,9 +26,9 @@
|
||||
#include <testsuite_tr1.h>
|
||||
|
||||
using namespace __gnu_test;
|
||||
using std::unique_future;
|
||||
template class unique_future<int>;
|
||||
template class unique_future<int&>;
|
||||
template class unique_future<void>;
|
||||
template class unique_future<ClassType>;
|
||||
template class unique_future<ClassType&>;
|
||||
using std::future;
|
||||
template class future<int>;
|
||||
template class future<int&>;
|
||||
template class future<void>;
|
||||
template class future<ClassType>;
|
||||
template class future<ClassType&>;
|
||||
|
Loading…
Reference in New Issue
Block a user