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

Detailed Description

template<typename... T>
class seastar::shared_promise< T >

Like promise except that its counterpart is shared_future instead of future.

When the shared_promise is made ready, every waiter is also made ready.

Like the shared_future, the types in the parameter pack T must all be copy-constructible.

#include <shared_future.hh>

Public Types

using shared_future_type = shared_future< T... >
 
using future_type = typename shared_future_type::future_type
 
using promise_type = typename shared_future_type::promise_type
 
using clock = typename shared_future_type::clock
 
using time_point = typename shared_future_type::time_point
 
using value_tuple_type = typename shared_future_type::value_tuple_type
 
using future_state_type = typename shared_future_type::future_state_type
 

Public Member Functions

 shared_promise (const shared_promise &)=delete
 
 shared_promise (shared_promise &&)=default
 
shared_promiseoperator= (shared_promise &&)=default
 
future_type get_shared_future (time_point timeout=time_point::max()) const
 Gets new future associated with this promise. If the promise is not resolved before timeout the returned future will resolve with timed_out_error. This instance doesn't have to be kept alive until the returned future resolves.
 
void set_value (const value_tuple_type &result) noexcept(copy_noexcept)
 Sets the shared_promise's value (as tuple; by copying), same as normal promise.
 
void set_value (value_tuple_type &&result) noexcept
 Sets the shared_promise's value (as tuple; by moving), same as normal promise.
 
template<typename... A>
void set_value (A &&... a) noexcept
 Sets the shared_promise's value (variadic), same as normal promise.
 
void set_exception (std::exception_ptr ex) noexcept
 Marks the shared_promise as failed, same as normal promise.
 
template<typename Exception >
void set_exception (Exception &&e) noexcept
 Marks the shared_promise as failed, same as normal promise.
 
bool available () const noexcept
 Returns true if the underlying future is available (ready or failed)
 
bool failed () const noexcept
 Returns true if the underlying future is failed.
 

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