C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
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 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.
 
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 , class... Ts>
delegated_response_type_t< Handle, detail::implicit_conversions_t< std::decay_t< Ts > >... > delegate (const Handle &receiver, Ts &&... args)
 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 , class... Ts>
delegated_response_type_t< Handle, detail::implicit_conversions_t< std::decay_t< Ts > >... > caf::response_promise::delegate ( const Handle & receiver,
Ts &&... args )

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 files: