aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/future
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include/future')
-rw-r--r--libcxx/include/future70
1 files changed, 44 insertions, 26 deletions
diff --git a/libcxx/include/future b/libcxx/include/future
index cedab3608ad2..2f14a471c458 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -367,21 +367,19 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
#include <__chrono/time_point.h>
#include <__config>
#include <__memory/allocator_arg_t.h>
+#include <__memory/allocator_destructor.h>
#include <__memory/uses_allocator.h>
+#include <__type_traits/strip_signature.h>
#include <__utility/auto_cast.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <exception>
-#include <memory>
#include <mutex>
+#include <new>
#include <system_error>
#include <thread>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <chrono>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -518,7 +516,7 @@ public:
const error_code& code() const _NOEXCEPT {return __ec_;}
future_error(const future_error&) _NOEXCEPT = default;
- virtual ~future_error() _NOEXCEPT;
+ ~future_error() _NOEXCEPT override;
};
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
@@ -544,7 +542,7 @@ protected:
mutable condition_variable __cv_;
unsigned __state_;
- virtual void __on_zero_shared() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
void __sub_wait(unique_lock<mutex>& __lk);
public:
enum
@@ -627,11 +625,13 @@ class _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_HIDDEN __assoc_state
: public __assoc_sub_state
{
typedef __assoc_sub_state base;
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
typedef typename aligned_storage<sizeof(_Rp), alignment_of<_Rp>::value>::type _Up;
+_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
_Up __value_;
- virtual void __on_zero_shared() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
public:
template <class _Arg>
@@ -641,7 +641,7 @@ public:
void set_value_at_thread_exit(_Arg&& __arg);
_Rp move();
- typename add_lvalue_reference<_Rp>::type copy();
+ __add_lvalue_reference_t<_Rp> copy();
};
template <class _Rp>
@@ -687,18 +687,18 @@ __assoc_state<_Rp>::move()
unique_lock<mutex> __lk(this->__mut_);
this->__sub_wait(__lk);
if (this->__exception_ != nullptr)
- rethrow_exception(this->__exception_);
+ std::rethrow_exception(this->__exception_);
return _VSTD::move(*reinterpret_cast<_Rp*>(&__value_));
}
template <class _Rp>
-typename add_lvalue_reference<_Rp>::type
+__add_lvalue_reference_t<_Rp>
__assoc_state<_Rp>::copy()
{
unique_lock<mutex> __lk(this->__mut_);
this->__sub_wait(__lk);
if (this->__exception_ != nullptr)
- rethrow_exception(this->__exception_);
+ std::rethrow_exception(this->__exception_);
return *reinterpret_cast<_Rp*>(&__value_);
}
@@ -711,7 +711,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __assoc_state<_Rp&>
protected:
_Up __value_;
- virtual void __on_zero_shared() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
public:
void set_value(_Rp& __arg);
@@ -758,7 +758,7 @@ __assoc_state<_Rp&>::copy()
unique_lock<mutex> __lk(this->__mut_);
this->__sub_wait(__lk);
if (this->__exception_ != nullptr)
- rethrow_exception(this->__exception_);
+ std::rethrow_exception(this->__exception_);
return *__value_;
}
@@ -823,7 +823,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __assoc_sub_state_alloc
typedef __assoc_sub_state base;
_Alloc __alloc_;
- virtual void __on_zero_shared() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
public:
_LIBCPP_INLINE_VISIBILITY
explicit __assoc_sub_state_alloc(const _Alloc& __a)
@@ -895,7 +895,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit __deferred_assoc_state(_Fp&& __f);
- virtual void __execute();
+ void __execute() override;
};
template <class _Fp>
@@ -982,12 +982,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state<void, _Fp>
_Fp __func_;
- virtual void __on_zero_shared() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
public:
_LIBCPP_INLINE_VISIBILITY
explicit __async_assoc_state(_Fp&& __f);
- virtual void __execute();
+ void __execute() override;
};
template <class _Fp>
@@ -1628,7 +1628,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_base<_Rp(_ArgTypes...)>
public:
_LIBCPP_INLINE_VISIBILITY
__packaged_task_base() {}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL
virtual ~__packaged_task_base() {}
virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0;
virtual void destroy() = 0;
@@ -1704,7 +1704,9 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_function<_Rp(_ArgTypes...)>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_NO_CFI
__base* __get_buf() { return (__base*)&__buf_; }
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
typename aligned_storage<3*sizeof(void*)>::type __buf_;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
__base* __f_;
public:
@@ -1754,7 +1756,7 @@ template <class _Fp>
__packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
: __f_(nullptr)
{
- typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
+ typedef __libcpp_remove_reference_t<typename decay<_Fp>::type> _FR;
typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;
if (sizeof(_FF) <= sizeof(__buf_))
{
@@ -1778,7 +1780,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
allocator_arg_t, const _Alloc& __a0, _Fp&& __f)
: __f_(nullptr)
{
- typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
+ typedef __libcpp_remove_reference_t<typename decay<_Fp>::type> _FR;
typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF;
if (sizeof(_FF) <= sizeof(__buf_))
{
@@ -1837,7 +1839,9 @@ __packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f)
{
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
{
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
__base* __t = (__base*)&__tempbuf;
__f_->__move_to(__t);
__f_->destroy();
@@ -1891,11 +1895,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
packaged_task() _NOEXCEPT : __p_(nullptr) {}
template <class _Fp,
- class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
+ class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
_LIBCPP_INLINE_VISIBILITY
explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
template <class _Fp, class _Allocator,
- class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
+ class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
_LIBCPP_INLINE_VISIBILITY
packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
@@ -2006,11 +2010,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
packaged_task() _NOEXCEPT : __p_(nullptr) {}
template <class _Fp,
- class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
+ class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
_LIBCPP_INLINE_VISIBILITY
explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
template <class _Fp, class _Allocator,
- class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
+ class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
_LIBCPP_INLINE_VISIBILITY
packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
@@ -2053,6 +2057,16 @@ public:
void reset();
};
+#if _LIBCPP_STD_VER >= 17
+
+template <class _Rp, class... _Args>
+packaged_task(_Rp(*)(_Args...)) -> packaged_task<_Rp(_Args...)>;
+
+template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>
+packaged_task(_Fp) -> packaged_task<_Stripped>;
+
+#endif
+
template<class ..._ArgTypes>
void
packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args)
@@ -2174,7 +2188,7 @@ inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, lau
{ return (int(__policy) & int(__value)) != 0; }
template <class _Fp, class... _Args>
-_LIBCPP_NODISCARD_AFTER_CXX17
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type>
async(launch __policy, _Fp&& __f, _Args&&... __args)
{
@@ -2436,4 +2450,8 @@ future<void>::share() _NOEXCEPT
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
+# include <chrono>
+#endif
+
#endif // _LIBCPP_FUTURE