Google Cloud C++ Client  1.32.1
C++ Client Library for Google Cloud Platform
Public Member Functions | List of all members
google::cloud::v1::promise< T > Class Template Referencefinal

Implement promise<T> as defined in ISO/IEC TS 19571:2016. More...

#include <google/cloud/future_generic.h>

Public Member Functions

 promise ()
 Creates a promise with an unsatisfied shared state. More...
 
 promise (std::function< void()> cancellation_callback)
 Creates a promise with an unsatisfied shared state. More...
 
 promise (null_promise_t x)
 Creates a promise without a shared state. More...
 
 promise (promise &&)=default
 Constructs a new promise and transfer any shared state from rhs. More...
 
promiseoperator= (promise &&rhs) noexcept
 Abandons the shared state in *this, if any, and transfers the shared state from rhs. More...
 
 ~promise ()=default
 Abandons any shared state. More...
 
 promise (promise const &)=delete
 
promiseoperator= (promise const &)=delete
 
void swap (promise &other) noexcept
 Swaps the shared state in *this with rhs. More...
 
future< T > get_future ()
 Creates the future<T> using the same shared state as *this. More...
 
void set_value (T value)
 Satisfies the shared state. More...
 

Detailed Description

template<typename T>
class google::cloud::v1::promise< T >

Implement promise<T> as defined in ISO/IEC TS 19571:2016.

Definition at line 135 of file future_generic.h.

Constructor & Destructor Documentation

◆ promise() [1/5]

template<typename T >
google::cloud::v1::promise< T >::promise ( )
inline

Creates a promise with an unsatisfied shared state.

Definition at line 138 of file future_generic.h.

◆ promise() [2/5]

template<typename T >
google::cloud::v1::promise< T >::promise ( std::function< void()>  cancellation_callback)
inlineexplicit

Creates a promise with an unsatisfied shared state.

Definition at line 141 of file future_generic.h.

◆ promise() [3/5]

template<typename T >
google::cloud::v1::promise< T >::promise ( null_promise_t  x)
inlineexplicit

Creates a promise without a shared state.

Definition at line 145 of file future_generic.h.

◆ promise() [4/5]

template<typename T >
google::cloud::v1::promise< T >::promise ( promise< T > &&  )
default

Constructs a new promise and transfer any shared state from rhs.

◆ ~promise()

template<typename T >
google::cloud::v1::promise< T >::~promise ( )
default

Abandons any shared state.

If the shared state was not already satisfied it becomes satisfied with a std::future_error exception. The error code in this exception is std::future_errc::broken_promise.

◆ promise() [5/5]

template<typename T >
google::cloud::v1::promise< T >::promise ( promise< T > const &  )
delete

Member Function Documentation

◆ get_future()

template<typename T >
future<T> google::cloud::v1::promise< T >::get_future ( )
inline

Creates the future<T> using the same shared state as *this.

Definition at line 180 of file future_generic.h.

◆ operator=() [1/2]

template<typename T >
promise& google::cloud::v1::promise< T >::operator= ( promise< T > &&  rhs)
inlinenoexcept

Abandons the shared state in *this, if any, and transfers the shared state from rhs.

Definition at line 154 of file future_generic.h.

◆ operator=() [2/2]

template<typename T >
promise& google::cloud::v1::promise< T >::operator= ( promise< T > const &  )
delete

◆ set_value()

template<typename T >
void google::cloud::v1::promise< T >::set_value ( value)
inline

Satisfies the shared state.

Exceptions
std::future_errorwith std::future_errc::promise_already_satisfied if the shared state is already satisfied.
std::future_errorwith std::no_state if the promise does not have a shared state.

Definition at line 193 of file future_generic.h.

◆ swap()

template<typename T >
void google::cloud::v1::promise< T >::swap ( promise< T > &  other)
inlinenoexcept

Swaps the shared state in *this with rhs.

Definition at line 173 of file future_generic.h.