C++ Actor Framework 0.18
Loading...
Searching...
No Matches
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>

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
 
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.
 
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.
 
void deliver (error x)
 Satisfies the promise by sending an error message.
 
void deliver ()
 Satisfies the promise by sending an empty message.
 
void deliver (unit_t)
 Satisfies the promise by sending an empty message.
 
template<class... Ts>
void deliver (Ts... xs)
 Satisfies the promise by sending make_message(xs...).
 
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.
 
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.
 

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 ( )

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() [2/6]

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

Satisfies the promise by sending an error message.

Postcondition
pending() == false

◆ deliver() [3/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

◆ deliver() [4/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() [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]

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

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