actor-framework
fwd.hpp
1 // This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
2 // the main distribution directory for license terms and copyright or visit
3 // https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
4 
5 #pragma once
6 
7 #include "caf/detail/core_export.hpp"
8 
9 #include <cstddef>
10 #include <cstdint>
11 #include <memory>
12 #include <string_view>
13 #include <utility>
14 #include <variant>
15 #include <vector>
16 
17 namespace caf {
18 
19 // clang-format off
20 
21 // -- 1 param templates --------------------------------------------------------
22 
23 template <class> class [[nodiscard]] error_code;
24 
25 template <class> class actor_from_state_t;
26 template <class> class basic_cow_string;
27 template <class> class callback;
28 template <class> class cow_vector;
29 template <class> class dictionary;
30 template <class> class expected;
31 template <class> class intrusive_cow_ptr;
32 template <class> class intrusive_ptr;
33 template <class> class span;
34 template <class> class typed_stream;
35 template <class> class weak_intrusive_ptr;
36 
37 template <class> struct inspector_access;
38 template <class> struct timeout_definition;
39 template <class> struct type_id;
40 
41 template <uint16_t> struct type_by_id;
42 template <uint16_t> struct type_name_by_id;
43 
44 // -- 2 param templates --------------------------------------------------------
45 
46 template <class Iterator, class Sentinel = Iterator> struct parser_state;
47 
48 // -- 3 param templates --------------------------------------------------------
49 
50 template <class, class, int> class actor_cast_access;
51 
52 template <class K, class V, class = std::allocator<std::pair<K, V>>>
54 
55 // -- variadic templates -------------------------------------------------------
56 
57 template <class...> class blocking_delayed_response_handle;
58 template <class...> class blocking_response_handle;
59 template <class...> class const_typed_message_view;
60 template <class...> class cow_tuple;
61 template <class...> class delegated;
62 template <class...> class event_based_delayed_response_handle;
63 template <class...> class event_based_response_handle;
64 template <class...> class result;
65 template <class...> class typed_actor;
66 template <class...> class typed_actor_pointer;
67 template <class...> class typed_actor_view;
68 template <class...> class typed_behavior;
69 template <class...> class typed_event_based_actor;
70 template <class...> class typed_message_view;
71 template <class...> class typed_response_promise;
72 
73 // clang-format on
74 
75 // -- classes ------------------------------------------------------------------
76 
77 class [[nodiscard]] error;
78 class abstract_actor;
79 class abstract_mailbox;
80 class action;
81 class actor;
82 class actor_addr;
83 class actor_clock;
84 class actor_companion;
85 class actor_config;
87 class actor_pool;
88 class actor_proxy;
89 class actor_registry;
90 class actor_system;
93 class attachable;
94 class behavior;
96 class binary_serializer;
97 class blocking_actor;
98 class chunk;
99 class chunked_string;
100 class config_option;
101 class config_option_adder;
102 class config_option_set;
103 class config_value;
104 class deserializer;
105 class disposable;
106 class event_based_actor;
108 class hashed_node_id;
109 class ipv4_address;
110 class ipv4_endpoint;
111 class ipv4_subnet;
112 class ipv6_address;
113 class ipv6_endpoint;
114 class ipv6_subnet;
115 class json_array;
116 class json_object;
117 class json_reader;
118 class json_value;
119 class json_writer;
120 class local_actor;
121 class logger;
122 class mail_cache;
123 class mailbox_element;
124 class message;
125 class message_builder;
126 class message_handler;
127 class message_id;
128 class node_id;
129 class node_id_data;
130 class proxy_registry;
131 class ref_counted;
132 class response_promise;
133 class resumable;
134 class scheduled_actor;
135 class scoped_actor;
136 class serializer;
137 class skip_t;
138 class skippable_result;
139 class stream;
140 class type_id_list;
141 class uri;
142 class uri_builder;
143 class uuid;
144 
145 // -- templates with default parameters ----------------------------------------
146 
147 template <class, class = event_based_actor>
149 
150 // -- structs ------------------------------------------------------------------
151 
152 struct down_msg;
153 struct dynamically_typed;
154 struct exit_msg;
156 struct invalid_actor_addr_t;
157 struct invalid_actor_t;
158 struct node_down_msg;
159 struct none_t;
161 struct stream_abort_msg;
162 struct stream_ack_msg;
163 struct stream_batch_msg;
164 struct stream_cancel_msg;
165 struct stream_close_msg;
166 struct stream_demand_msg;
167 struct stream_open_msg;
168 struct timeout_msg;
169 struct unit_t;
170 
171 // -- free template functions --------------------------------------------------
172 
173 template <class T>
174 config_option make_config_option(std::string_view category,
175  std::string_view name,
176  std::string_view description);
177 
178 template <class T>
179 config_option make_config_option(T& storage, std::string_view category,
180  std::string_view name,
181  std::string_view description);
182 
183 // -- enums --------------------------------------------------------------------
184 
185 enum class exit_reason : uint8_t;
186 enum class invoke_message_result;
187 enum class pec : uint8_t;
188 enum class sec : uint8_t;
189 enum class thread_owner;
190 
191 // -- aliases ------------------------------------------------------------------
192 
193 using actor_id = uint64_t;
194 using byte_buffer = std::vector<std::byte>;
195 using byte_span = span<std::byte>;
204 using type_id_t = uint16_t;
205 
206 // -- functions ----------------------------------------------------------------
207 
209 CAF_CORE_EXPORT const settings& content(const actor_system_config&);
210 
211 // -- hash inspectors ----------------------------------------------------------
212 
213 namespace hash {
214 
215 template <class>
216 class fnv;
217 
218 } // namespace hash
219 
220 // -- marker classes for mixins ------------------------------------------------
221 
222 namespace mixin {
223 
224 struct subscriber_base;
225 
226 } // namespace mixin
227 
228 // -- telemetry API ------------------------------------------------------------
229 
230 namespace telemetry {
231 
232 class component;
233 class dbl_gauge;
234 class int_gauge;
235 class label;
236 class label_view;
237 class metric;
238 class metric_family;
239 class metric_registry;
240 class timer;
241 
242 enum class metric_type : uint8_t;
243 
244 template <class ValueType>
245 class counter;
246 
247 template <class ValueType>
248 class histogram;
249 
250 template <class Type>
252 
253 template <class Type>
255 
260 
267 
268 } // namespace telemetry
269 
270 namespace detail {
271 
272 class actor_system_access;
274 class mailbox_factory;
276 
277 template <class>
279 
280 template <>
282  using type = telemetry::dbl_gauge;
283 };
284 
285 template <>
287  using type = telemetry::int_gauge;
288 };
289 
291 template <class ValueType>
292 using gauge_oracle_t = typename gauge_oracle<ValueType>::type;
293 
294 } // namespace detail
295 
296 namespace telemetry {
297 
298 template <class ValueType>
299 using gauge = detail::gauge_oracle_t<ValueType>;
300 
301 } // namespace telemetry
302 
303 // -- I/O classes --------------------------------------------------------------
304 
305 namespace io {
306 
307 class broker;
308 class middleman;
309 template <class...>
311 
312 namespace basp {
313 
314 struct header;
315 
316 } // namespace basp
317 
318 } // namespace io
319 
320 // -- networking classes -------------------------------------------------------
321 
322 namespace net {
323 
324 class middleman;
325 
326 } // namespace net
327 
328 // -- scheduler classes --------------------------------------------------------
329 
330 class scheduler;
331 
332 // -- log classes --------------------------------------------------------------
333 
334 namespace log {
335 
336 class event;
337 class event_fields;
338 class event_sender;
339 
340 using event_ptr = intrusive_ptr<event>;
341 
342 } // namespace log
343 
344 // -- OpenSSL classes ----------------------------------------------------------
345 
346 namespace openssl {
347 
348 class manager;
349 
350 } // namespace openssl
351 
352 // -- detail classes -----------------------------------------------------------
353 
354 namespace detail {
355 
356 class abstract_worker;
357 class abstract_worker_hub;
358 class disposer;
359 class dynamic_message_data;
360 class message_data;
361 class private_thread;
362 class stream_bridge;
363 class stream_bridge_sub;
364 
365 struct meta_object;
366 
367 // enable intrusive_cow_ptr<dynamic_message_data> with forward declaration only
368 CAF_CORE_EXPORT void intrusive_ptr_add_ref(const dynamic_message_data*);
369 CAF_CORE_EXPORT void intrusive_ptr_release(const dynamic_message_data*);
370 CAF_CORE_EXPORT dynamic_message_data*
371 intrusive_cow_ptr_unshare(dynamic_message_data*&);
372 
374 
375 } // namespace detail
376 
377 // -- weak pointer aliases -----------------------------------------------------
378 
380 
381 // -- intrusive pointer aliases ------------------------------------------------
382 
384 
385 // -- unique pointer aliases ---------------------------------------------------
386 
387 using mailbox_element_ptr = std::unique_ptr<mailbox_element>;
388 
389 // -- shared pointer aliases ---------------------------------------------------
390 
391 using shared_action_ptr = std::shared_ptr<callback<void()>>;
392 
393 } // namespace caf
Sent to all links when an actor is terminated.
Definition: system_messages.hpp:22
This helper class identifies an expected response message and enables request(...).then(...).
Definition: blocking_response_handle.hpp:130
Utility to override internal components of an actor system.
Definition: actor_system_access.hpp:13
Maps the type T to a globally unique ID.
Definition: fwd.hpp:39
invoke_message_result
Stores the result of a message invocation.
Definition: invoke_message_result.hpp:14
Definition: ipv4_subnet.hpp:15
config_option make_config_option(std::string_view category, std::string_view name, std::string_view description)
Creates a config option that synchronizes with storage.
Definition: make_config_option.hpp:53
The base class for all mailbox implementations.
Definition: mailbox_factory.hpp:13
Definition: ipv6_subnet.hpp:18
uint16_t type_id_t
Internal representation of a type ID.
Definition: fwd.hpp:204
Definition: node_id.hpp:72
A map abstraction with an unsorted std::vector providing O(n) lookup.
Definition: fwd.hpp:53
A cooperatively scheduled entity.
Definition: resumable.hpp:15
Definition: stream_bridge.hpp:18
Manages brokers and network backends.
Definition: middleman.hpp:34
Definition: abstract_worker.hpp:14
Non-cryptographic hash algorithm (variant 1a) named after Glenn Fowler, Landon Curt Noll...
Definition: fwd.hpp:216
Definition: prohibit_top_level_spawn_marker.hpp:9
Wraps the result of a message handler to represent either a value (wrapped into a message)...
Definition: fwd.hpp:64
Stores all information necessary for implementing an FSM-based parser.
Definition: fwd.hpp:46
An co-existing actor forwarding all messages through a user-defined callback to another object...
Definition: actor_companion.hpp:27
Helper class to indicate that a request has been forwarded.
Definition: delegated.hpp:13
Groups a (distributed) set of actors and allows actors in the same namespace to exchange messages...
Definition: proxy_registry.hpp:25
Base class for actors running on this node, either living in an own thread or cooperatively scheduled...
Definition: local_actor.hpp:41
Describes the behavior of an actor, i.e., provides a message handler and an optional timeout...
Definition: behavior.hpp:24
An IP endpoint that contains an ::ipv4_address and a port.
Definition: ipv4_endpoint.hpp:17
Adds config options of the same category to a config_option_set.
Definition: config_option_adder.hpp:16
sec
SEC stands for "System Error Code".
Definition: sec.hpp:25
thread_owner
Denotes the component that launched a CAF thread.
Definition: thread_owner.hpp:15
Serializes an inspectable object to a JSON-formatted string.
Definition: json_writer.hpp:15
A thread-mapped or context-switching actor using a blocking receive rather than a behavior-stack base...
Definition: blocking_actor.hpp:42
exit_reason
This error category represents fail conditions for actors.
Definition: exit_reason.hpp:25
Asks the source for more data.
Definition: system_messages.hpp:135
Provides a convenient interface for creating message objects from a series of values using the member...
Definition: message_builder.hpp:21
A functional interface similar to std::function<void()> with dispose semantics.
Definition: action.hpp:23
An intrusive, reference counting smart pointer implementation.
Definition: fwd.hpp:32
Definition: stream_bridge.hpp:84
Definition: node_id.hpp:24
Describes a fixed-length, copy-on-write, type-erased tuple with elements of any type.
Definition: message.hpp:32
Definition: private_thread.hpp:18
Informs the sink that a stream has reached the end.
Definition: system_messages.hpp:208
Actor environment including scheduler, registry, and optional components such as a middleman...
Definition: actor_system.hpp:86
A metric that represents a single integer value that can arbitrarily go up and down.
Definition: int_gauge.hpp:20
Definition: actor_system_config_access.hpp:14
A serializable type for storing error codes with category and optional, human-readable context inform...
Definition: error.hpp:50
A set of config_option objects that parses CLI arguments into a settings object.
Definition: config_option_set.hpp:24
A coordinator creates the workers, manages delayed sends and the central printer instance for aout...
Definition: scheduler.hpp:21
Sent to all actors monitoring an actor when it is terminated.
Definition: system_messages.hpp:48
Tag type to indicate that the sender of a message is a dynamically typed actor.
Definition: dynamically_typed.hpp:13
Definition: fwd.hpp:251
Definition: type_id_list.test.cpp:24
Stores the address of typed as well as untyped actors.
Definition: actor_addr.hpp:21
An event-based actor with managed state.
Definition: fwd.hpp:148
Similar to blocking_response_handle, but also holds the disposable for the delayed request message...
Definition: blocking_response_handle.hpp:197
An actor poool is a lightweight abstraction for a set of workers.
Definition: actor_pool.hpp:40
A URI according to RFC 3986.
Definition: uri.hpp:25
pec
PEC stands for "Parser Error Code".
Definition: pec.hpp:20
Marker class identifying classes in CAF that are not allowed to be used as message element...
Definition: illegal_message_element.hpp:13
Enables destroying, constructing and serializing objects through type-erased pointers.
Definition: meta_object.hpp:19
Definition: fwd.hpp:66
An IP endpoint that contains an ::ipv6_address and a port.
Definition: ipv6_endpoint.hpp:18
Represents "nothing", e.g., for clearing an optional by assigning none.
Definition: none.hpp:14
Definition: type_id_list.test.cpp:11
Informs the sink that the source has added it to the flow.
Definition: system_messages.hpp:166
Definition: const_typed_message_view.hpp:18
Serializes C++ objects into a sequence of bytes.
Definition: binary_serializer.hpp:25
Informs the source that the sender is no longer interest in receiving items from this stream...
Definition: system_messages.hpp:153
Provides access to a statically typed, potentially unbound sequence of items emitted by an actor...
Definition: fwd.hpp:34
Represents an actor running on a remote machine, or different hardware, or in a separate process...
Definition: actor_proxy.hpp:18
An intrusive, reference counting smart pointer implementation.
Definition: fwd.hpp:35
Definition: fwd.hpp:254
Defines a configuration option for the application.
Definition: config_option.hpp:19
Base class for reference counted objects with an atomic reference count.
Definition: ref_counted.hpp:19
A typed broker mediates between actor systems and other components in the network.
Definition: fwd.hpp:310
A cooperatively scheduled, event-based actor implementation.
Definition: scheduled_actor.hpp:73
A metric that represents a single integer value that can arbitrarily go up and down.
Definition: dbl_gauge.hpp:18
An (optional) component of the actor system.
Definition: actor_system_module.hpp:13
Represents an immutable JSON value.
Definition: json_value.hpp:18
Definition: fwd.hpp:38
Definition: fwd.hpp:70
A scoped handle to a blocking actor.
Definition: scoped_actor.hpp:17
Definition: mailbox_element.hpp:19
Signals a timeout to an actor.
Definition: system_messages.hpp:74
Definition: actor_cast.hpp:64
This helper class identifies an expected response message and enables request(...).then(...).
Definition: event_based_response_handle.hpp:101
Bundles various flags along with an optional request ID.
Definition: message_id.hpp:21
Callback utility class.
Definition: attachable.hpp:23
A monotonic clock for scheduling timeouts and delayed messages.
Definition: actor_clock.hpp:17
Deserializes C++ objects from sequence of bytes.
Definition: binary_deserializer.hpp:26
Technology-independent deserialization interface.
Definition: deserializer.hpp:24
A cooperatively scheduled, event-based actor implementation.
Definition: event_based_actor.hpp:28
Identifies an untyped actor.
Definition: actor.hpp:28
Base class for all actor implementations.
Definition: abstract_actor.hpp:48
Replacement for std::pmr::monotonic_buffer_resource, which sadly is not available on all platforms CA...
Definition: monotonic_buffer_resource.hpp:29
A central place where workers return to after finishing a task.
Definition: abstract_worker_hub.hpp:21
Customization point for adding support for a custom type.
Definition: fwd.hpp:37
Stores spawn-time settings and flags.
Definition: actor_config.hpp:16
Represents a JSON object.
Definition: json_object.hpp:17
Unit is analogous to void, but can be safely returned, stored, etc.
Definition: unit.hpp:16
Maps the globally unique ID V to a type (inverse to ::type_id).
Definition: fwd.hpp:41
A node ID is an opaque value for representing CAF instances in the network.
Definition: node_id.hpp:111
A list of type IDs, stored in a size-prefix, contiguous memory block.
Definition: type_id_list.hpp:21
A registry is used to associate actors to IDs or names.
Definition: actor_registry.hpp:32
Definition: fwd.hpp:67
Definition: ipv4_address.hpp:18
Actors are always allocated with a control block that stores its identity as well as strong and weak ...
Definition: actor_control_block.hpp:51
Asks a source to add another sink.
Definition: system_messages.hpp:115
Definition: skip.hpp:18
Maps the globally unique ID V to a type name.
Definition: fwd.hpp:42
A C++11/14 drop-in replacement for C++20&#39;s std::span without support for static extents.
Definition: fwd.hpp:33
Similar to result<message>, but also allows to skip a message.
Definition: result.hpp:241
Transfers items from a source to a sink.
Definition: system_messages.hpp:191
Represents a JSON array.
Definition: json_array.hpp:18
const settings & content(const actor_system_config &cfg)
Returns all user-provided configuration parameters.
Definition: actor_system_config.cpp:596
Sent to all actors monitoring a node when CAF loses connection to it.
Definition: system_messages.hpp:85
Implements a simple proxy forwarding all operations to a manager.
Definition: forwarding_actor_proxy.hpp:16
Represent aggregatable distributions of events.
Definition: fwd.hpp:248
A type for config parameters with similar interface to a variant.
Definition: config_value.hpp:71
Definition: fwd.hpp:68
Represents a disposable resource.
Definition: disposable.hpp:15
Root namespace of libcaf.
Definition: custom_types_4.cpp:139
A partial function implementation used to process a message.
Definition: message_handler.hpp:27
Definition: fwd.hpp:278
Technology-independent serialization interface.
Definition: serializer.hpp:26
Represents a chunked string as a linked list of string views.
Definition: chunked_string.hpp:23
std::vector< std::byte > byte_buffer
A buffer for storing binary data.
Definition: byte_buffer.hpp:13
A simple cache for storing mailbox elements for an actor for later reuse.
Definition: mail_cache.hpp:18
Enables actors to delay a response message by capturing the context of a request message.
Definition: response_promise.hpp:24
Definition: fwd.hpp:65
Provides access to a potentially unbound sequence of items emitted by an actor.
Definition: stream.hpp:24
Definition: ipv6_address.hpp:20
Similar to event_based_response_handle, but also holds the disposable for the delayed request message...
Definition: event_based_response_handle.hpp:230
Centrally logs events from all actors in an actor system.
Definition: logger.hpp:33
The base class for all mailbox implementations.
Definition: abstract_mailbox.hpp:15
A universally unique identifier according to RFC 4122.
Definition: uuid.hpp:24
Container for storing an arbitrary number of message elements.
Definition: message_data.hpp:33
Deserializes an inspectable object from a JSON-formatted string.
Definition: json_reader.hpp:17
Definition: fwd.hpp:69
An implicitly shared type for binary data.
Definition: chunk.hpp:32
A copy-on-write tuple implementation.
Definition: cow_tuple.hpp:18
Definition: uri_builder.hpp:16
Informs the sink that a stream has been aborted due to an unrecoverable error.
Definition: system_messages.hpp:222
An intrusive, reference counting smart pointer implementation with copy-on-write optimization.
Definition: fwd.hpp:31
A metric that represents a single value that can only go up.
Definition: fwd.hpp:245
Configures an actor_system on startup.
Definition: actor_system_config.hpp:28
Enables statically typed actors to delay a response message by capturing the context of a request mes...
Definition: fwd.hpp:71