7 #include "caf/actor.hpp" 8 #include "caf/actor_addr.hpp" 9 #include "caf/actor_cast.hpp" 10 #include "caf/detail/core_export.hpp" 11 #include "caf/detail/send_type_check.hpp" 12 #include "caf/intrusive_ptr.hpp" 13 #include "caf/message.hpp" 14 #include "caf/message_id.hpp" 15 #include "caf/response_type.hpp" 30 friend class stream_manager;
50 bool async()
const noexcept;
53 bool pending()
const noexcept;
71 void deliver(
error x);
89 template <
class... Ts>
92 static_assert(!detail::tl_exists_v<arg_types, detail::is_result>,
93 "delivering a result<T> is not supported");
94 static_assert(!detail::tl_exists_v<arg_types, detail::is_expected>,
95 "mixing expected<T> with regular values is not supported");
97 state_->deliver_impl(make_message(std::move(xs)...));
109 if constexpr (std::is_same_v<T, void> || std::is_same_v<T, unit_t>)
110 state_->deliver_impl(make_message());
112 state_->deliver_impl(make_message(std::move(*x)));
114 state_->deliver_impl(make_message(std::move(x.
error())));
124 template <message_priority P = message_priority::normal,
class Handle,
127 detail::implicit_conversions_t<std::decay_t<Ts>>...>
129 static_assert(
sizeof...(Ts) > 0,
"no message to send");
130 detail::send_type_check<
none_t, Handle, Ts...>();
132 if constexpr (P == message_priority::high)
133 state_->id = state_->id.with_high_priority();
136 state_->delegate_impl(actor_cast<abstract_actor*>(receiver),
137 std::forward<Ts>(args)...);
139 state_->delegate_impl(actor_cast<abstract_actor*>(receiver),
140 make_message(std::forward<Ts>(args)...));
169 class CAF_CORE_EXPORT state {
172 state(
const state&) =
delete;
173 state& operator=(
const state&) =
delete;
178 void deliver_impl(
message msg);
182 mutable size_t ref_count = 1;
187 friend void intrusive_ptr_add_ref(
const state* ptr) {
191 friend void intrusive_ptr_release(
const state* ptr) {
192 if (--ptr->ref_count == 0)
Base class for actors running on this node, either living in an own thread or cooperatively scheduled...
Definition: local_actor.hpp:41
typename response_type< typename Handle::signatures, In... >::delegated_type delegated_response_type_t
Computes the response message type for input In... from the list of message passing interfaces Fs and...
Definition: response_type.hpp:61
A list of types.
Definition: type_list.hpp:11
Describes a fixed-length, copy-on-write, type-erased tuple with elements of any type.
Definition: message.hpp:32
A serializable type for storing error codes with category and optional, human-readable context inform...
Definition: error.hpp:50
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...
Definition: response_promise.hpp:106
void deliver(Ts... xs)
Satisfies the promise by sending make_message(xs...).
Definition: response_promise.hpp:90
caf::error & error() &noexcept
Definition: expected.hpp:290
void deliver(unit_t)
Satisfies the promise by sending an empty message.
Definition: response_promise.hpp:83
Represents "nothing", e.g., for clearing an optional by assigning none.
Definition: none.hpp:14
Definition: mailbox_element.hpp:19
Represents the result of a computation which can either complete successfully with an instance of typ...
Definition: expected.hpp:45
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.
Definition: response_promise.hpp:128
Bundles various flags along with an optional request ID.
Definition: message_id.hpp:21
Base class for all actor implementations.
Definition: abstract_actor.hpp:48
Unit is analogous to void, but can be safely returned, stored, etc.
Definition: unit.hpp:16
Root namespace of libcaf.
Definition: custom_types_4.cpp:139
Enables actors to delay a response message by capturing the context of a request message.
Definition: response_promise.hpp:24
Enables statically typed actors to delay a response message by capturing the context of a request mes...
Definition: fwd.hpp:71