hpx/async_distributed/promise.hpp#
Defined in header hpx/async_distributed/promise.hpp.
See Public API for a list of names and headers that are part of the public HPX API.
-
template<>
class promise<void, hpx::util::unused_type> : public lcos::detail::promise_base<void, hpx::util::unused_type, lcos::detail::promise_data<void>># Public Functions
-
promise() = default#
constructs a promise object and a shared state.
-
template<typename Allocator>
inline promise(std::allocator_arg_t, Allocator const &a)# constructs a promise object and a shared state. The constructor uses the allocator a to allocate the memory for the shared state.
-
promise(promise &&other) noexcept = default#
constructs a new promise object and transfers ownership of the shared state of other (if any) to the newly- constructed object.
- Post
other has no shared state.
-
~promise() = default#
Abandons any shared state.
-
promise &operator=(promise &&other) noexcept = default#
Abandons any shared state (30.6.4) and then as if promise(HPX_MOVE(other)).swap(*this).
- Returns
*this.
-
inline void swap(promise &other) noexcept#
Exchanges the shared state of *this and other.
- Post
*this has the shared state (if any) that other had prior to the call to swap. other has the shared state (if any) that *this had prior to the call to swap.
-
inline void set_value()#
atomically stores the value r in the shared state and makes that state ready (30.6.4).
- Throws
future_error – if its shared state already has a stored value. if shared state has no stored value exception is raised. promise_already_satisfied if its shared state already has a stored value or exception. no_state if *this has no shared state.
-
promise() = default#
-
template<typename R, typename Allocator>
struct uses_allocator<hpx::distributed::promise<R>, Allocator> : public true_type# - #include <promise.hpp>
Requires: Allocator shall be an allocator (17.6.3.5)
-
namespace hpx
-
namespace distributed
Functions
-
template<typename Result, typename RemoteResult>
void swap(promise<Result, RemoteResult> &x, promise<Result, RemoteResult> &y) noexcept#
-
template<typename Result, typename RemoteResult>
class promise : public lcos::detail::promise_base<Result, RemoteResult, lcos::detail::promise_data<Result>> - #include <promise.hpp>
A promise can be used by a single thread to invoke a (remote) action and wait for the result. The result is expected to be sent back to the promise using the LCO’s set_event action
A promise is one of the simplest synchronization primitives provided by HPX. It allows to synchronize on a eager evaluated remote operation returning a result of the type Result. The promise allows to synchronize exactly one thread (the one passed during construction time).
// Create the promise (the expected result is a id_type) hpx::distributed::promise<hpx::id_type> p; // Get the associated future future<hpx::id_type> f = p.get_future(); // initiate the action supplying the promise as a // continuation apply<some_action>(new continuation(p.get_id()), ...); // Wait for the result to be returned, yielding control // in the meantime. hpx::id_type result = f.get(); // ...
Note
The action executed by the promise must return a value of a type convertible to the type as specified by the template parameter RemoteResult
- Template Parameters
Result – The template parameter Result defines the type this promise is expected to return from promise::get.
RemoteResult – The template parameter RemoteResult defines the type this promise is expected to receive from the remote action.
Public Functions
-
promise() = default#
constructs a promise object and a shared state.
-
template<typename Allocator>
inline promise(std::allocator_arg_t, Allocator const &a)# constructs a promise object and a shared state. The constructor uses the allocator a to allocate the memory for the shared state.
-
promise(promise &&other) noexcept = default#
constructs a new promise object and transfers ownership of the shared state of other (if any) to the newly- constructed object.
- Post
other has no shared state.
-
~promise() = default#
Abandons any shared state.
- template<> unused_type > : public lcos::detail::promise_base< void, hpx::util::unused_type, lcos::detail::promise_data< void > >
Public Functions
-
promise() = default#
constructs a promise object and a shared state.
-
template<typename Allocator>
inline promise(std::allocator_arg_t, Allocator const &a)# constructs a promise object and a shared state. The constructor uses the allocator a to allocate the memory for the shared state.
-
promise(promise &&other) noexcept = default#
constructs a new promise object and transfers ownership of the shared state of other (if any) to the newly- constructed object.
- Post
other has no shared state.
-
~promise() = default#
Abandons any shared state.
-
promise &operator=(promise &&other) noexcept = default#
Abandons any shared state (30.6.4) and then as if promise(HPX_MOVE(other)).swap(*this).
- Returns
*this.
-
inline void swap(promise &other) noexcept#
Exchanges the shared state of *this and other.
- Post
*this has the shared state (if any) that other had prior to the call to swap. other has the shared state (if any) that *this had prior to the call to swap.
-
inline void set_value()#
atomically stores the value r in the shared state and makes that state ready (30.6.4).
- Throws
future_error – if its shared state already has a stored value. if shared state has no stored value exception is raised. promise_already_satisfied if its shared state already has a stored value or exception. no_state if *this has no shared state.
-
promise() = default#
-
template<typename Result, typename RemoteResult>
-
namespace distributed
-
namespace std
- template<typename R, typename Allocator> promise< R >, Allocator > : public true_type
- #include <promise.hpp>
Requires: Allocator shall be an allocator (17.6.3.5)