futures

The contents of this module can be included with the header hpx/modules/futures.hpp. These headers may be used by user-code but are not guaranteed stable (neither header location nor contents). You are using these at your own risk. If you wish to use non-public functionality from a module we strongly suggest only including the module header hpx/modules/futures.hpp, not the particular header in which the functionality you would like to use is defined. See Public API for a list of names that are part of the public HPX API.

Defines

HPX_MAKE_EXCEPTIONAL_FUTURE(T, errorcode, f, msg)
namespace hpx
namespace lcos

Functions

template<typename R, typename U>
hpx::lcos::future<R> make_future(hpx::lcos::future<U> &&f)
template<typename R, typename U, typename Conv>
hpx::lcos::future<R> make_future(hpx::lcos::future<U> &&f, Conv &&conv)
template<typename R, typename U>
hpx::lcos::future<R> make_future(hpx::lcos::shared_future<U> f)
template<typename R, typename U, typename Conv>
hpx::lcos::future<R> make_future(hpx::lcos::shared_future<U> f, Conv &&conv)
template<typename R>
hpx::lcos::shared_future<R> make_shared_future(hpx::lcos::future<R> &&f)
template<typename R>
hpx::lcos::shared_future<R> &make_shared_future(hpx::lcos::shared_future<R> &f)
template<typename R>
hpx::lcos::shared_future<R> &&make_shared_future(hpx::lcos::shared_future<R> &&f)
template<typename R>
hpx::lcos::shared_future<R> const &make_shared_future(hpx::lcos::shared_future<R> const &f)
template<typename T, typename Allocator, typename ...Ts>
std::enable_if<std::is_constructible<T, Ts&&...>::value || std::is_void<T>::value, future<T>>::type make_ready_future_alloc(Allocator const &a, Ts&&... ts)
template<typename T, typename ...Ts>
std::enable_if<std::is_constructible<T, Ts&&...>::value || std::is_void<T>::value, future<T>>::type make_ready_future(Ts&&... ts)
template<int DeductionGuard = 0, typename Allocator, typename T>
future<typename hpx::util::decay_unwrap<T>::type> make_ready_future_alloc(Allocator const &a, T &&init)
template<int DeductionGuard = 0, typename T>
future<typename hpx::util::decay_unwrap<T>::type> make_ready_future(T &&init)
template<typename T>
future<T> make_exceptional_future(std::exception_ptr const &e)
template<typename T, typename E>
future<T> make_exceptional_future(E e)
template<int DeductionGuard = 0, typename T>
future<typename hpx::util::decay_unwrap<T>::type> make_ready_future_at(hpx::chrono::steady_time_point const &abs_time, T &&init)
template<int DeductionGuard = 0, typename T>
future<typename hpx::util::decay_unwrap<T>::type> make_ready_future_after(hpx::chrono::steady_duration const &rel_time, T &&init)
template<typename Allocator>
future<void> make_ready_future_alloc(Allocator const &a)
future<void> make_ready_future()
future<void> make_ready_future_at(hpx::chrono::steady_time_point const &abs_time)
future<void> make_ready_future_after(hpx::chrono::steady_duration const &rel_time)
template<typename R>
class future : public hpx::lcos::detail::future_base<future<R>, R>

Public Types

template<>
using result_type = R
template<>
using shared_state_type = typename base_type::shared_state_type

Public Functions

future()
future(future &&other)
future(future<future> &&other)
future(future<shared_future<R>> &&other)
template<typename T>
future(future<T> &&other, typename std::enable_if<std::is_void<R>::value && !traits::is_future<T>::value, T>::type* = nullptr)
~future()
future &operator=(future &&other)
shared_future<R> share()
hpx::traits::future_traits<future>::result_type get()
hpx::traits::future_traits<future>::result_type get(error_code &ec)
template<typename F>
decltype(auto) then(F &&f, error_code &ec = throws)
template<typename T0, typename F>
decltype(auto) then(T0 &&t0, F &&f, error_code &ec = throws)
template<typename Allocator, typename F>
auto then_alloc(Allocator const &alloc, F &&f, error_code &ec = throws)

Private Types

template<>
using base_type = detail::future_base<future<R>, R>

Private Functions

future(hpx::intrusive_ptr<shared_state_type> const &state)
future(hpx::intrusive_ptr<shared_state_type> &&state)
template<typename SharedState>
future(hpx::intrusive_ptr<SharedState> const &state)

Friends

friend hpx::lcos::hpx::traits::future_access
template<typename Receiver>
detail::operation_state<Receiver, future> tag_invoke(hpx::execution::experimental::connect_t, future &&f, Receiver &&receiver)
struct invalidate

Public Functions

template<>
invalidate(future &f)
template<>
~invalidate()

Public Members

template<>
future &f_
template<typename R>
class shared_future : public hpx::lcos::detail::future_base<shared_future<R>, R>

Public Types

template<>
using result_type = R
template<>
using shared_state_type = typename base_type::shared_state_type

Public Functions

shared_future()
shared_future(shared_future const &other)
shared_future(shared_future &&other)
shared_future(future<R> &&other)
shared_future(future<shared_future> &&other)
template<typename T>
shared_future(shared_future<T> const &other, typename std::enable_if<std::is_void<R>::value && !traits::is_future<T>::value, T>::type* = nullptr)
~shared_future()
shared_future &operator=(shared_future const &other)
shared_future &operator=(shared_future &&other)
hpx::traits::future_traits<shared_future>::result_type get() const
hpx::traits::future_traits<shared_future>::result_type get(error_code &ec) const
template<typename F>
decltype(auto) then(F &&f, error_code &ec = throws) const
template<typename T0, typename F>
decltype(auto) then(T0 &&t0, F &&f, error_code &ec = throws) const
template<typename Allocator, typename F>
auto then_alloc(Allocator const &alloc, F &&f, error_code &ec = throws)

Private Types

typedef detail::future_base<shared_future<R>, R> base_type

Private Functions

shared_future(hpx::intrusive_ptr<shared_state_type> const &state)
shared_future(hpx::intrusive_ptr<shared_state_type> &&state)
template<typename SharedState>
shared_future(hpx::intrusive_ptr<SharedState> const &state)

Friends

friend hpx::lcos::hpx::traits::future_access
template<typename Receiver>
detail::operation_state<Receiver, shared_future> tag_invoke(hpx::execution::experimental::connect_t, shared_future &&f, Receiver &&receiver)
template<typename Receiver>
detail::operation_state<Receiver, shared_future> tag_invoke(hpx::execution::experimental::connect_t, shared_future &f, Receiver &&receiver)
namespace serialization

Functions

template<typename Archive, typename T>
void serialize(Archive &ar, ::hpx::lcos::future<T> &f, unsigned version)
template<typename Archive, typename T>
void serialize(Archive &ar, ::hpx::lcos::shared_future<T> &f, unsigned version)
namespace hpx
namespace lcos
namespace local
template<typename Result, bool Cancelable>
class futures_factory<Result(), Cancelable>

Public Functions

futures_factory()
template<typename Executor, typename F>
futures_factory(Executor &exec, F &&f)
template<typename Executor>
futures_factory(Executor &exec, Result (*f)())
template<typename F, typename Enable = typename std::enable_if<!std::is_same<typename std::decay<F>::type, futures_factory>::value>::type>
futures_factory(F &&f)
futures_factory(Result (*f)())
~futures_factory()
futures_factory(futures_factory const &rhs)
futures_factory &operator=(futures_factory const &rhs)
futures_factory(futures_factory &&rhs)
futures_factory &operator=(futures_factory &&rhs)
void operator()() const
threads::thread_id_ref_type apply(const char *annotation = "futures_factory::apply", launch policy = launch::async, error_code &ec = throws) const
threads::thread_id_ref_type apply(threads::thread_pool_base *pool, const char *annotation = "futures_factory::apply", launch policy = launch::async, error_code &ec = throws) const
lcos::future<Result> get_future(error_code &ec = throws)
bool valid() const
void set_exception(std::exception_ptr const &e)

Protected Types

typedef lcos::detail::task_base<Result> task_impl_type

Protected Attributes

hpx::intrusive_ptr<task_impl_type> task_
bool future_obtained_
namespace hpx
namespace lcos
namespace local
template<typename R, typename ...Ts>
class packaged_task<R(Ts...)>

Public Functions

packaged_task()
template<typename F, typename FD = std::decay_t<F>, typename Enable = std::enable_if_t<!std::is_same_v<FD, packaged_task> && is_invocable_r_v<R, FD&, Ts...>>>
packaged_task(F &&f)
template<typename Allocator, typename F, typename FD = std::decay_t<F>, typename Enable = std::enable_if_t<!std::is_same_v<FD, packaged_task> && is_invocable_r_v<R, FD&, Ts...>>>
packaged_task(std::allocator_arg_t, Allocator const &a, F &&f)
packaged_task(packaged_task const &rhs)
packaged_task(packaged_task &&rhs)
packaged_task &operator=(packaged_task const &rhs)
packaged_task &operator=(packaged_task &&rhs)
void swap(packaged_task &rhs)
void operator()(Ts... ts)
lcos::future<R> get_future(error_code &ec = throws)
bool valid() const
void reset(error_code &ec = throws)
void set_exception(std::exception_ptr const &e)

Private Types

template<>
using function_type = util::unique_function_nonser<R(Ts...)>

Private Members

function_type function_
local::promise<R> promise_
namespace std

Functions

template<typename Sig>
void swap(hpx::lcos::local::packaged_task<Sig> &lhs, hpx::lcos::local::packaged_task<Sig> &rhs)
namespace hpx
namespace lcos
namespace local

Functions

template<typename R>
void swap(promise<R> &x, promise<R> &y)
template<typename R>
class promise : public hpx::lcos::local::detail::promise_base<R>

Public Functions

promise()
template<typename Allocator>
promise(std::allocator_arg_t, Allocator const &a)
promise(promise &&other)
~promise()
promise &operator=(promise &&other)
void swap(promise &other)
void set_value(R const &r)
void set_value(R &&r)
template<typename ...Ts>
void set_value(Ts&&... ts)

Private Types

template<>
using base_type = detail::promise_base<R>
template<typename R>
class promise<R&> : public hpx::lcos::local::detail::promise_base<R&>

Public Functions

promise()
template<typename Allocator>
promise(std::allocator_arg_t, Allocator const &a)
promise(promise &&other)
~promise()
promise &operator=(promise &&other)
void swap(promise &other)
void set_value(R &r)

Private Types

template<>
using base_type = detail::promise_base<R&>
template<>
class promise<void> : public hpx::lcos::local::detail::promise_base<void>

Public Functions

promise()
template<typename Allocator>
promise(std::allocator_arg_t, Allocator const &a)
promise(promise &&other)
~promise()
promise &operator=(promise &&other)
void swap(promise &other)
void set_value()

Private Types

template<>
using base_type = detail::promise_base<void>
namespace hpx
namespace traits
struct acquire_future_disp

Public Functions

template<typename T>
acquire_future<T>::type operator()(T &&t) const
namespace hpx
namespace traits
struct acquire_shared_state_disp

Public Functions

template<typename T>
acquire_shared_state<T>::type operator()(T &&t) const
template<typename R>
struct future_access<lcos::future<R>>

Public Static Functions

template<typename SharedState>
static lcos::future<R> create(hpx::intrusive_ptr<SharedState> const &shared_state)
template<typename T = void>
static lcos::future<R> create(detail::shared_state_ptr_for_t<lcos::future<lcos::future<R>>> const &shared_state)
template<typename SharedState>
static lcos::future<R> create(hpx::intrusive_ptr<SharedState> &&shared_state)
template<typename T = void>
static lcos::future<R> create(detail::shared_state_ptr_for_t<lcos::future<lcos::future<R>>> &&shared_state)
template<typename SharedState>
static lcos::future<R> create(SharedState *shared_state, bool addref = true)
static traits::detail::shared_state_ptr_t<R> const &get_shared_state(lcos::future<R> const &f)
static traits::detail::shared_state_ptr_t<R>::element_type *detach_shared_state(lcos::future<R> &&f)
template<typename Destination>
static void transfer_result(lcos::future<R> &&src, Destination &dest)

Private Static Functions

template<typename Destination>
static void transfer_result_impl(lcos::future<R> &&src, Destination &dest, std::false_type)
template<typename Destination>
static void transfer_result_impl(lcos::future<R> &&src, Destination &dest, std::true_type)
template<typename R>
struct future_access<lcos::shared_future<R>>

Public Static Functions

template<typename SharedState>
static lcos::shared_future<R> create(hpx::intrusive_ptr<SharedState> const &shared_state)
template<typename T = void>
static lcos::shared_future<R> create(detail::shared_state_ptr_for_t<lcos::shared_future<lcos::future<R>>> const &shared_state)
template<typename SharedState>
static lcos::shared_future<R> create(hpx::intrusive_ptr<SharedState> &&shared_state)
template<typename T = void>
static lcos::shared_future<R> create(detail::shared_state_ptr_for_t<lcos::shared_future<lcos::future<R>>> &&shared_state)
template<typename SharedState>
static lcos::shared_future<R> create(SharedState *shared_state, bool addref = true)
static traits::detail::shared_state_ptr_t<R> const &get_shared_state(lcos::shared_future<R> const &f)
static traits::detail::shared_state_ptr_t<R>::element_type *detach_shared_state(lcos::shared_future<R> const &f)
template<typename Destination>
static void transfer_result(lcos::shared_future<R> &&src, Destination &dest)

Private Static Functions

template<typename Destination>
static void transfer_result_impl(lcos::shared_future<R> &&src, Destination &dest, std::false_type)
template<typename Destination>
static void transfer_result_impl(lcos::shared_future<R> &&src, Destination &dest, std::true_type)
namespace hpx
namespace traits
template<typename R>
struct future_access<lcos::future<R>>

Public Static Functions

template<typename SharedState>
static lcos::future<R> create(hpx::intrusive_ptr<SharedState> const &shared_state)
template<typename T = void>
static lcos::future<R> create(detail::shared_state_ptr_for_t<lcos::future<lcos::future<R>>> const &shared_state)
template<typename SharedState>
static lcos::future<R> create(hpx::intrusive_ptr<SharedState> &&shared_state)
template<typename T = void>
static lcos::future<R> create(detail::shared_state_ptr_for_t<lcos::future<lcos::future<R>>> &&shared_state)
template<typename SharedState>
static lcos::future<R> create(SharedState *shared_state, bool addref = true)
static traits::detail::shared_state_ptr_t<R> const &get_shared_state(lcos::future<R> const &f)
static traits::detail::shared_state_ptr_t<R>::element_type *detach_shared_state(lcos::future<R> &&f)
template<typename Destination>
static void transfer_result(lcos::future<R> &&src, Destination &dest)

Private Static Functions

template<typename Destination>
static void transfer_result_impl(lcos::future<R> &&src, Destination &dest, std::false_type)
template<typename Destination>
static void transfer_result_impl(lcos::future<R> &&src, Destination &dest, std::true_type)
template<typename R>
struct future_access<lcos::shared_future<R>>

Public Static Functions

template<typename SharedState>
static lcos::shared_future<R> create(hpx::intrusive_ptr<SharedState> const &shared_state)
template<typename T = void>
static lcos::shared_future<R> create(detail::shared_state_ptr_for_t<lcos::shared_future<lcos::future<R>>> const &shared_state)
template<typename SharedState>
static lcos::shared_future<R> create(hpx::intrusive_ptr<SharedState> &&shared_state)
template<typename T = void>
static lcos::shared_future<R> create(detail::shared_state_ptr_for_t<lcos::shared_future<lcos::future<R>>> &&shared_state)
template<typename SharedState>
static lcos::shared_future<R> create(SharedState *shared_state, bool addref = true)
static traits::detail::shared_state_ptr_t<R> const &get_shared_state(lcos::shared_future<R> const &f)
static traits::detail::shared_state_ptr_t<R>::element_type *detach_shared_state(lcos::shared_future<R> const &f)
template<typename Destination>
static void transfer_result(lcos::shared_future<R> &&src, Destination &dest)

Private Static Functions

template<typename Destination>
static void transfer_result_impl(lcos::shared_future<R> &&src, Destination &dest, std::false_type)
template<typename Destination>
static void transfer_result_impl(lcos::shared_future<R> &&src, Destination &dest, std::true_type)
namespace hpx
namespace traits

Typedefs

template<typename Future, typename F>
using future_then_result_t = typename future_then_result<Future, F>::type
template<typename R>
struct future_traits<lcos::future<R>>

Public Types

template<>
using type = R
template<>
using result_type = R
template<typename R>
struct future_traits<lcos::shared_future<R>>

Public Types

template<>
using type = R
template<>
using result_type = R const&
template<>
struct future_traits<lcos::shared_future<void>>

Public Types

template<>
using type = void
template<>
using result_type = void
namespace hpx
namespace traits

Typedefs

template<typename Future>
using future_traits_t = typename future_traits<Future>::type
template<typename R>
struct future_traits<lcos::future<R>>

Public Types

template<>
using type = R
template<>
using result_type = R
template<typename R>
struct future_traits<lcos::shared_future<R>>

Public Types

template<>
using type = R
template<>
using result_type = R const&
template<>
struct future_traits<lcos::shared_future<void>>

Public Types

template<>
using type = void
template<>
using result_type = void
namespace hpx
namespace traits
template<typename Result, typename RemoteResult, typename Enable = void>
struct get_remote_result

Public Static Functions

static Result call(RemoteResult const &rhs)
static Result call(RemoteResult &&rhs)
template<typename Result>
struct get_remote_result<Result, Result>

Public Static Functions

static Result const &call(Result const &rhs)
static Result &&call(Result &&rhs)
namespace hpx
namespace traits

Variables

template<typename R>
constexpr bool is_future_v = is_future<R>::value
template<typename R>
constexpr bool is_ref_wrapped_future_v = is_ref_wrapped_future<R>::value
template<typename Future>
struct is_future : public hpx::traits::detail::is_future_customization_point<Future>

Subclassed by hpx::traits::is_ref_wrapped_future< std::reference_wrapper< Future > >

namespace hpx
namespace traits
template<typename R>
struct future_range_traits<R, true>

Public Types

typedef range_traits<R>::value_type future_type
template<>
struct promise_local_result<util::unused_type>

Public Types

template<>
using type = void
namespace hpx
namespace traits

Typedefs

template<typename Result>
using promise_local_result_t = typename promise_local_result<Result>::type
template<typename Result, typename Enable = void>
struct promise_local_result

Public Types

template<>
using type = Result
template<>
struct promise_local_result<util::unused_type>

Public Types

template<>
using type = void
namespace hpx
namespace traits

Typedefs

template<typename Result>
using promise_remote_result_t = typename promise_remote_result<Result>::type
template<typename Result, typename Enable = void>
struct promise_remote_result

Public Types

typedef Result type
template<>
struct promise_remote_result<void>

Public Types

typedef hpx::util::unused_type type