Provides a mechanism to access the result of asynchronous operations. More...
Public Member Functions | |
futures (std::unique_ptr< handle_type > p) | |
futures (handle_type &h) | |
size_type | size (void) const |
Returns how many results are or will be stored. | |
T | get (const size_type n) |
Returns the n-th result. More... | |
aggregate_result_type | get (void) |
Returns all the results. More... | |
bool | valid (const size_type n) const |
Returns true if the n-th result is available. | |
bool | valid (void) const |
Returns true if all the results are available. | |
void | wait (const size_type n) const |
Waits for the n-th result to become available. More... | |
void | wait (void) const |
Waits for all the results to become available. More... | |
template<typename Function > | |
void | async_then (Function &&f) |
Executes f when the results are available. More... | |
Public Types | |
using | handle_type = runtime::futures_base< T > |
using | size_type = typename handle_type::size_type |
using | aggregate_result_type = typename handle_type::aggregate_result_type |
Provides a mechanism to access the result of asynchronous operations.
T | Object type. |
The result in this case is one or more objects, so there are functions to check, wait on and return individual elements.
T stapl::futures< T >::get | ( | const size_type | n | ) |
Returns the n-th result.
This function waits until the n-th result is available and returns it. valid(n)==false
after a call to this method.
aggregate_result_type stapl::futures< T >::get | ( | void | ) |
Returns all the results.
This function waits until all results are available and returns them. valid()==false
after a call to this method.
void stapl::futures< T >::wait | ( | const size_type | n | ) | const |
Waits for the n-th result to become available.
Blocks until valid(n)==true
.
void stapl::futures< T >::wait | ( | void | ) | const |
Waits for all the results to become available.
Blocks until valid()==true
.
void stapl::futures< T >::async_then | ( | Function && | f | ) |
Executes f
when the results are available.
If the result is already available, then the function is executed in-place.