Handle for receiving one result. More...
Public Member Functions | |
bool | valid (void) const final |
Returns true if the result has been received. | |
void | wait (void) const final |
Waits for the result to be received. More... | |
void | wait (context &ctx) const |
Waits for the result to be received. More... | |
R | get (void) final |
Returns the received result. More... | |
R | get (context &ctx) |
Returns the received result. More... | |
void | set_value (storage_type *const p, void *const base, message_shared_ptr &m) |
Sets the result. More... | |
void | set_value (R const &value) |
Sets the result. More... | |
void | set_value (R &&value) |
Sets the result. More... | |
void | set_owned (void) noexcept |
bool | is_owned (void) const noexcept |
void | async_then (Function &&f) |
Public Types | |
typedef internal_storage_type::storage_type | storage_type |
using | value_type = R |
Protected Member Functions | |
bool | valid_no_yield (void) const noexcept final |
Returns true if the result has been received. | |
void | schedule_continuation (void) |
Schedules a continuation if async_then() was called. | |
Protected Attributes | |
std::mutex | m_mtx |
Handle for receiving one result.
R | Result type. |
|
finalvirtual |
Waits for the result to be received.
Blocks until valid() const returns true
.
Implements stapl::runtime::future_base< R >.
void stapl::runtime::value_handle< R >::wait | ( | context & | ctx | ) | const |
Waits for the result to be received.
Blocks until valid() const returns true
.
|
finalvirtual |
Returns the received result.
This function waits until the result has been received and returns it.
Calling valid() const returns false
after a call to this function.
The lock ensures that set_value() has finished before the get() continues, to avoid calling schedule_continuation() on an object that has been destroyed.
Implements stapl::runtime::future_base< R >.
R stapl::runtime::value_handle< R >::get | ( | context & | ctx | ) |
Returns the received result.
This function waits until the result has been received and returns it.
Calling valid() const returns false
after a call to this function.
The lock ensures that set_value() has finished before the get() continues, to avoid calling schedule_continuation() on an object that has been destroyed.
void stapl::runtime::value_handle< R >::set_value | ( | storage_type *const | p, |
void *const | base, | ||
message_shared_ptr & | m | ||
) |
Sets the result.
This function keeps a pointer to the buffer where the result remains packed until get() is called.
p | Pointer to the stapl::runtime::arg_storage in the buffer. |
base | Address in the buffer that the stapl::runtime::arg_storage is stored in. |
m | Buffer that contains the stapl::runtime::arg_storage . |
void stapl::runtime::value_handle< R >::set_value | ( | R const & | value | ) |
Sets the result.
value | Value to be set. |
void stapl::runtime::value_handle< R >::set_value | ( | R && | value | ) |
Sets the result.
value | Value to be set. |