C++ Actor Framework  0.18
Public Types | Public Member Functions | Friends | List of all members
caf::response_promise Class Reference

Enables actors to delay a response message by capturing the context of a request message. More...

#include <response_promise.hpp>

Collaboration diagram for caf::response_promise:
Collaboration graph

Public Types

using forwarding_stack = std::vector< strong_actor_ptr >
 

Public Member Functions

 response_promise (response_promise &&)=default
 
 response_promise (const response_promise &)=default
 
response_promiseoperator= (response_promise &&)=default
 
response_promiseoperator= (const response_promise &)=default
 
 response_promise (none_t)
 
bool async () const noexcept
 Returns whether this response promise replies to an asynchronous message.
 
bool pending () const noexcept
 Queries whether this promise is a valid promise that is not satisfied yet.
 
strong_actor_ptr source () const noexcept
 Returns the source of the corresponding request.
 
forwarding_stack stages () const
 Returns the remaining stages for the corresponding request.
 
strong_actor_ptr next () const noexcept
 Returns the actor that will receive the response, i.e., stages().front() if !stages().empty() or source() otherwise. More...
 
message_id id () const noexcept
 Returns the message ID of the corresponding request.
 
void deliver (message msg)
 Satisfies the promise by sending the given message. More...
 
void deliver (error x)
 Satisfies the promise by sending an error message. More...
 
void deliver ()
 Satisfies the promise by sending an empty message. More...
 
void deliver (unit_t)
 Satisfies the promise by sending an empty message. More...
 
template<class... Ts>
void deliver (Ts... xs)
 Satisfies the promise by sending make_message(xs...). More...
 
template<class T >
void deliver (expected< T > x)
 Satisfies the promise by sending the content of x, i.e., either a value of type T or an error. More...
 
template<message_priority P = message_priority::normal, class Handle = actor, class... Ts>
delegated_response_type_t< typename Handle::signatures, detail::implicit_conversions_t< typename std::decay< Ts >::type >... > delegate (const Handle &dest, Ts &&... xs)
 Satisfies the promise by delegating to another actor. More...
 

Friends

class local_actor
 
class stream_manager
 
template<class... >
class typed_response_promise
 

Detailed Description

Enables actors to delay a response message by capturing the context of a request message.

This is particularly useful when an actor needs to communicate to other actors in order to fulfill a request for a client.

Member Function Documentation

◆ delegate()

template<message_priority P = message_priority::normal, class Handle = actor, class... Ts>
delegated_response_type_t< typename Handle::signatures, detail::implicit_conversions_t<typename std::decay<Ts>::type>...> caf::response_promise::delegate ( const Handle &  dest,
Ts &&...  xs 
)

Satisfies the promise by delegating to another actor.

Postcondition
pending() == false

◆ deliver() [1/6]

void caf::response_promise::deliver ( message  msg)

Satisfies the promise by sending the given message.

Note
Drops empty messages silently when responding to an asynchronous request message, i.e., if async() == true.
Postcondition
pending() == false

◆ deliver() [2/6]

void caf::response_promise::deliver ( error  x)

Satisfies the promise by sending an error message.

Postcondition
pending() == false

◆ deliver() [3/6]

void caf::response_promise::deliver ( )

Satisfies the promise by sending an empty message.

Note
Sends no message if the request message was asynchronous, i.e., if async() == true.
Postcondition
pending() == false

◆ deliver() [4/6]

void caf::response_promise::deliver ( unit_t  )

Satisfies the promise by sending an empty message.

Note
Sends no message if the request message was asynchronous, i.e., if async() == true.
Postcondition
pending() == false

◆ deliver() [5/6]

template<class... Ts>
void caf::response_promise::deliver ( Ts...  xs)

Satisfies the promise by sending make_message(xs...).

Postcondition
pending() == false

◆ deliver() [6/6]

template<class T >
void caf::response_promise::deliver ( expected< T >  x)

Satisfies the promise by sending the content of x, i.e., either a value of type T or an error.

Postcondition
pending() == false

◆ next()

strong_actor_ptr caf::response_promise::next ( ) const
noexcept

Returns the actor that will receive the response, i.e., stages().front() if !stages().empty() or source() otherwise.


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