hpx::distributed::promise#

Defined in header hpx/future.hpp.

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx
namespace distributed
template<typename Result, typename RemoteResult>
class promise#
#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.

namespace lcos

Typedefs

using instead = hpx::distributed::promise<Result, RemoteResult>
template<typename Result, typename RemoteResult, typename ComponentTag>
class base_lco_with_value : public hpx::lcos::base_lco, public ComponentTag
#include <base_lco_with_value.hpp>
template<typename Action, typename Result = typename traits::promise_local_result<typename Action::remote_result_type>::type, bool DirectExecute = Action::direct_execution::value>
class packaged_action#
#include <packaged_action.hpp>

A packaged_action 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 packaged_action using the LCO’s set_event action

A packaged_action 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.

Note

The action executed using the packaged_action as a continuation must return a value of a type convertible to the type as specified by the template parameter Result.

Template Parameters
  • Action – The template parameter Action defines the action to be executed by this packaged_action instance. The arguments arg0,… argN are used as parameters for this action.

  • Result – The template parameter Result defines the type this packaged_action is expected to return from its associated future packaged_action::get_future.

  • DirectExecute – The template parameter DirectExecute is an optimization aid allowing to execute the action directly if the target is local (without spawning a new thread for this). This template does not have to be supplied explicitly as it is derived from the template parameter Action.

namespace lcos