STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
List of all members | Public Member Functions | Public Types
stapl::futures< T > Class Template Reference

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

Detailed Description

template<typename T>
class stapl::futures< T >

Provides a mechanism to access the result of asynchronous operations.

Template Parameters
TObject type.

The result in this case is one or more objects, so there are functions to check, wait on and return individual elements.

Member Function Documentation

◆ get() [1/2]

template<typename T >
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.

Warning
You cannot mix calls of this function and get().

◆ get() [2/2]

template<typename T >
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.

Warning
You cannot mix calls of this function and get(const size_type).

◆ wait() [1/2]

template<typename T >
void stapl::futures< T >::wait ( const size_type  n) const

Waits for the n-th result to become available.

Blocks until valid(n)==true.

◆ wait() [2/2]

template<typename T >
void stapl::futures< T >::wait ( void  ) const

Waits for all the results to become available.

Blocks until valid()==true.

◆ async_then()

template<typename T >
template<typename Function >
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.


The documentation for this class was generated from the following file: