A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
Loading...
Searching...
No Matches
a11::Promise< T > Class Template Reference

Move-only producer for a Future result. More...

#include <cpp/a11/concurrency/future.h>

Public Member Functions

 Promise ()
 
 Promise (const Promise &)=delete
 
Promiseoperator= (const Promise &)=delete
 
 Promise (Promise &&other) noexcept
 Transfer responsibility for completing or abandoning the shared state.
 
Promiseoperator= (Promise &&other) noexcept
 Abandon this state, then take responsibility for other's state.
 
 ~Promise ()
 
Future< Tfuture () const
 Return a consumer handle sharing this promise's completion state.
 
absl::Status SetCancellationCallback (std::function< void()> cancel)
 Install the operation invoked when a consumer calls Future::Cancel().
 
absl::Status SetValue (T value)
 Complete successfully with value.
 
absl::Status SetStatus (absl::Status status)
 Complete with a non-OK status.
 
absl::Status SetResult (absl::StatusOr< T > result)
 Complete with either a value or an error, waking every observer.
 

Detailed Description

template<typename T>
class a11::Promise< T >

Move-only producer for a Future result.

Obtain the consumer handle with future(), then complete the promise exactly once with SetValue(), SetStatus(), or SetResult(). Destroying an incomplete promise publishes a Cancelled status so agent pipelines cannot wait forever on an abandoned operation.

Constructor & Destructor Documentation

◆ Promise() [1/3]

template<typename T >
a11::Promise< T >::Promise ( )
inline

◆ Promise() [2/3]

template<typename T >
a11::Promise< T >::Promise ( const Promise< T > &  )
delete

◆ Promise() [3/3]

template<typename T >
a11::Promise< T >::Promise ( Promise< T > &&  other)
inlinenoexcept

Transfer responsibility for completing or abandoning the shared state.

◆ ~Promise()

template<typename T >
a11::Promise< T >::~Promise ( )
inline

Member Function Documentation

◆ future()

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

Return a consumer handle sharing this promise's completion state.

◆ operator=() [1/2]

template<typename T >
Promise & a11::Promise< T >::operator= ( const Promise< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
Promise & a11::Promise< T >::operator= ( Promise< T > &&  other)
inlinenoexcept

Abandon this state, then take responsibility for other's state.

◆ SetCancellationCallback()

template<typename T >
absl::Status a11::Promise< T >::SetCancellationCallback ( std::function< void()>  cancel)
inline

Install the operation invoked when a consumer calls Future::Cancel().

◆ SetResult()

template<typename T >
absl::Status a11::Promise< T >::SetResult ( absl::StatusOr< T result)
inline

Complete with either a value or an error, waking every observer.

◆ SetStatus()

template<typename T >
absl::Status a11::Promise< T >::SetStatus ( absl::Status  status)
inline

Complete with a non-OK status.

◆ SetValue()

template<typename T >
absl::Status a11::Promise< T >::SetValue ( T  value)
inline

Complete successfully with value.


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