Seastar
High performance C++ framework for concurrent servers
Public Member Functions | List of all members
seastar::promise< T > Class Template Reference

Detailed Description

template<typename T>
class seastar::promise< T >

promise - allows a future value to be made available at a later time.

Template Parameters
TA list of types to be carried as the result of the associated future. A list with two or more types is deprecated; use promise<std::tuple<T...>> instead.

#include <seastar/core/future.hh>

Inheritance diagram for seastar::promise< T >:

Public Member Functions

 promise () noexcept
 Constructs an empty promise. More...
 
void move_it (promise &&x) noexcept
 Moves a promise object.
 
 promise (promise &&x) noexcept
 
 promise (const promise &)=delete
 
promiseoperator= (promise &&x) noexcept
 
void operator= (const promise &)=delete
 
void set_to_current_exception () noexcept
 
future< T > get_future () noexcept
 Gets the promise's associated future. More...
 
template<typename... A>
void set_value (A &&... a) noexcept
 Sets the promises value. More...
 
void set_exception (std::exception_ptr &&ex) noexcept
 Marks the promise as failed. More...
 
void set_exception (const std::exception_ptr &ex) noexcept
 
template<typename Exception >
std::enable_if_t<!std::is_same_v< std::remove_reference_t< Exception >, std::exception_ptr >, void > set_exception (Exception &&e) noexcept
 Marks the promise as failed. More...
 

Constructor & Destructor Documentation

◆ promise()

template<typename T >
seastar::promise< T >::promise ( )
inlinenoexcept

Constructs an empty promise.

Creates promise with no associated future yet (see get_future()).

Member Function Documentation

◆ set_exception() [1/2]

template<typename T >
template<typename Exception >
std::enable_if_t<!std::is_same_v<std::remove_reference_t<Exception>, std::exception_ptr>, void> seastar::promise< T >::set_exception ( Exception &&  e)
inlinenoexcept

Marks the promise as failed.

Forwards the exception argument to the future and makes it available. May be called either before or after get_future().

◆ set_exception() [2/2]

template<typename T >
void seastar::promise< T >::set_exception ( std::exception_ptr &&  ex)
inlinenoexcept

Marks the promise as failed.

Forwards the exception argument to the future and makes it available. May be called either before or after get_future().

◆ set_to_current_exception()

template<typename T >
void seastar::promise< T >::set_to_current_exception ( )
inlinenoexcept

Set this promise to the current exception.

This is equivalent to set_exception(std::current_exception()), but expands to less code.

◆ set_value()

template<typename T >
template<typename... A>
void seastar::promise< T >::set_value ( A &&...  a)
inlinenoexcept

Sets the promises value.

Forwards the arguments and makes them available to the associated future. May be called either before or after get_future().

The arguments can have either the types the promise is templated with, or a corresponding std::tuple. That is, given a promise<int, double>, both calls are valid:

pr.set_value(42, 43.0); pr.set_value(std::tuple<int, double>(42, 43.0))


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