2010-02-05 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/future (swap(packaged_task<>&, packaged_task<>&),
swap(promise<>&, promise<>&)): Add; minor formatting fixes.
* testsuite/30_threads/packaged_task/cons/assign_neg.cc: Adjust
dg-error line number.
* testsuite/30_threads/packaged_task/cons/copy_neg.cc: Likewise.
* testsuite/30_threads/promise/cons/assign_neg.cc: Likewise.
* testsuite/30_threads/promise/cons/copy_neg.cc: Likewise.
From-SVN: r156522
+2010-02-05 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/std/future (swap(packaged_task<>&, packaged_task<>&),
+ swap(promise<>&, promise<>&)): Add; minor formatting fixes.
+ * testsuite/30_threads/packaged_task/cons/assign_neg.cc: Adjust
+ dg-error line number.
+ * testsuite/30_threads/packaged_task/cons/copy_neg.cc: Likewise.
+ * testsuite/30_threads/promise/cons/assign_neg.cc: Likewise.
+ * testsuite/30_threads/promise/cons/copy_neg.cc: Likewise.
+
2010-02-05 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_algobase.h (struct __iter_base): Rename to
2010-02-05 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_algobase.h (struct __iter_base): Rename to
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 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
//
// 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
// Now we can define the protected __basic_future constructors.
template<typename _Res>
// Now we can define the protected __basic_future constructors.
template<typename _Res>
- __basic_future<_Res>::__basic_future(const shared_future<_Res>& __sf)
+ inline __basic_future<_Res>::
+ __basic_future(const shared_future<_Res>& __sf)
: _M_state(__sf._M_state)
{ }
template<typename _Res>
: _M_state(__sf._M_state)
{ }
template<typename _Res>
- __basic_future<_Res>::__basic_future(shared_future<_Res>&& __sf)
+ inline __basic_future<_Res>::
+ __basic_future(shared_future<_Res>&& __sf)
: _M_state(std::move(__sf._M_state))
{ }
template<typename _Res>
: _M_state(std::move(__sf._M_state))
{ }
template<typename _Res>
- __basic_future<_Res>::__basic_future(future<_Res>&& __uf)
+ inline __basic_future<_Res>::
+ __basic_future(future<_Res>&& __uf)
: _M_state(std::move(__uf._M_state))
{ }
: _M_state(std::move(__uf._M_state))
{ }
- : _M_future(std::make_shared<_State>()), _M_storage(new _Res_type())
+ : _M_future(std::make_shared<_State>()),
+ _M_storage(new _Res_type())
{ }
promise(promise&& __rhs)
: _M_future(std::move(__rhs._M_future)),
{ }
promise(promise&& __rhs)
: _M_future(std::move(__rhs._M_future)),
- _M_storage(std::move(__rhs._M_storage))
+ _M_storage(std::move(__rhs._M_storage))
{ }
// TODO: needs allocator_arg_t
{ }
// TODO: needs allocator_arg_t
+ template<typename _Res>
+ inline void
+ swap(promise<_Res>& __x, promise<_Res>& __y)
+ { __x.swap(__y); }
+
/// Partial specialization for promise<R&>
template<typename _Res>
class promise<_Res&>
/// Partial specialization for promise<R&>
template<typename _Res>
class promise<_Res&>
- : _M_future(std::make_shared<_State>()), _M_storage(new _Res_type())
+ : _M_future(std::make_shared<_State>()),
+ _M_storage(new _Res_type())
{ }
promise(promise&& __rhs)
{ }
promise(promise&& __rhs)
promise(promise&& __rhs)
: _M_future(std::move(__rhs._M_future)),
promise(promise&& __rhs)
: _M_future(std::move(__rhs._M_future)),
- _M_storage(std::move(__rhs._M_storage))
+ _M_storage(std::move(__rhs._M_storage))
{
typename _StateT::_Ptr_type operator()()
{
{
typename _StateT::_Ptr_type operator()()
{
- __try {
- _M_state->_M_result->_M_set(_M_fn());
- } __catch(...) {
- _M_state->_M_result->_M_error = current_exception();
- }
+ __try
+ {
+ _M_state->_M_result->_M_set(_M_fn());
+ }
+ __catch(...)
+ {
+ _M_state->_M_result->_M_error = current_exception();
+ }
return std::move(_M_state->_M_result);
}
_StateT* _M_state;
return std::move(_M_state->_M_result);
}
_StateT* _M_state;
{
typename _StateT::_Ptr_type operator()()
{
{
typename _StateT::_Ptr_type operator()()
{
- __try {
- _M_fn();
- } __catch(...) {
- _M_state->_M_result->_M_error = current_exception();
- }
- return std::move(_M_state->_M_result);
+ __try
+ {
+ _M_fn();
+ }
+ __catch(...)
+ {
+ _M_state->_M_result->_M_error = current_exception();
+ }
+ return std::move(_M_state->_M_result);
}
_StateT* _M_state;
std::function<void()> _M_fn;
}
_StateT* _M_state;
std::function<void()> _M_fn;
+ template<typename _Res, typename... _ArgTypes>
+ void inline
+ swap(packaged_task<_Res(_ArgTypes...)>& __x,
+ packaged_task<_Res(_ArgTypes...)>& __y)
+ { __x.swap(__y); }
+
template<typename _Res>
class __future_base::_Deferred_state : public __future_base::_State
{
template<typename _Res>
class __future_base::_Deferred_state : public __future_base::_State
{
explicit
_Async_state(std::function<_Res()>&& __fn)
: _M_result(new _Result<_Res>()), _M_fn(std::move(__fn)),
explicit
_Async_state(std::function<_Res()>&& __fn)
: _M_result(new _Result<_Res>()), _M_fn(std::move(__fn)),
- _M_thread(mem_fn(&_Async_state::_M_do_run), this)
+ _M_thread(mem_fn(&_Async_state::_M_do_run), this)
{ }
~_Async_state() { _M_thread.join(); }
{ }
~_Async_state() { _M_thread.join(); }
typedef typename _Fn::result_type result_type;
std::shared_ptr<__future_base::_State> __state;
if (__policy == launch::async)
typedef typename _Fn::result_type result_type;
std::shared_ptr<__future_base::_State> __state;
if (__policy == launch::async)
- {
- typedef typename __future_base::_Async_state<result_type> _State;
- __state = std::make_shared<_State>(std::bind<result_type>(
+ {
+ typedef typename __future_base::_Async_state<result_type> _State;
+ __state = std::make_shared<_State>(std::bind<result_type>(
std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
- {
- typedef typename __future_base::_Deferred_state<result_type> _State;
- __state = std::make_shared<_State>(std::bind<result_type>(
+ {
+ typedef typename __future_base::_Deferred_state<result_type> _State;
+ __state = std::make_shared<_State>(std::bind<result_type>(
std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
return future<result_type>(__state);
}
return future<result_type>(__state);
}
async(_Fn&& __fn, _Args&&... __args)
{
return async(launch::any, std::forward<_Fn>(__fn),
async(_Fn&& __fn, _Args&&... __args)
{
return async(launch::any, std::forward<_Fn>(__fn),
- std::forward<_Args>(__args)...);
+ std::forward<_Args>(__args)...);
}
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
}
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
// { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" }
// { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" }
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 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
//
// 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
}
// { dg-error "used here" "" { target *-*-* } 32 }
}
// { dg-error "used here" "" { target *-*-* } 32 }
-// { dg-error "deleted function" "" { target *-*-* } 1209 }
+// { dg-error "deleted function" "" { target *-*-* } 1225 }
// { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" }
// { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" }
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 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
//
// 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
}
// { dg-error "used here" "" { target *-*-* } 31 }
}
// { dg-error "used here" "" { target *-*-* } 31 }
-// { dg-error "deleted function" "" { target *-*-* } 1208 }
+// { dg-error "deleted function" "" { target *-*-* } 1224 }
// { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" }
// { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" }
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 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
//
// 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
}
// { dg-error "used here" "" { target *-*-* } 32 }
}
// { dg-error "used here" "" { target *-*-* } 32 }
-// { dg-error "deleted function" "" { target *-*-* } 864 }
+// { dg-error "deleted function" "" { target *-*-* } 868 }
// { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" }
// { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" }
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 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
//
// 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
}
// { dg-error "used here" "" { target *-*-* } 31 }
}
// { dg-error "used here" "" { target *-*-* } 31 }
-// { dg-error "deleted function" "" { target *-*-* } 848 }
+// { dg-error "deleted function" "" { target *-*-* } 852 }