libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
Promise< T > Class Template Reference

Promise wrapping std::promise<T>. More...

#include <promise.h>

Public Member Functions

 Promise ()=default
 Constructs a Promise.
 
 ~Promise ()=default
 Destructor.
 
 Promise (const Promise &)=delete
 
Promiseoperator= (const Promise &)=delete
 
 Promise (Promise &&other)=default
 Move constructor.
 
Promiseoperator= (Promise &&other)=default
 Move assignment.
 
void setValue (T value)
 Sets the result value.
 
void setError (Error error)
 Sets an error on the promise.
 
Future< Tfuture ()
 Returns the Future associated with this Promise.
 

Detailed Description

template<typename T>
class Promise< T >

Promise wrapping std::promise<T>.

Used to set a result that will be retrieved via the associated Future<T>. Move-only (non-copyable).

Template Parameters
TThe result type.

Member Function Documentation

◆ future()

template<typename T >
Future< T > Promise< T >::future ( )
inline

Returns the Future associated with this Promise.

Returns
A Future<T> that will receive the result.

◆ setError()

template<typename T >
void Promise< T >::setError ( Error  error)
inline

Sets an error on the promise.

The associated Future will receive a default-constructed T. The error is communicated via an exception internally.

Parameters
errorThe error to set.

◆ setValue()

template<typename T >
void Promise< T >::setValue ( T  value)
inline

Sets the result value.

Parameters
valueThe value to make available to the Future.

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