7 #include "caf/abstract_actor.hpp" 8 #include "caf/actor_cast.hpp" 9 #include "caf/actor_clock.hpp" 10 #include "caf/detail/core_export.hpp" 11 #include "caf/detail/implicit_conversions.hpp" 12 #include "caf/detail/send_type_check.hpp" 13 #include "caf/disposable.hpp" 14 #include "caf/mailbox_element.hpp" 15 #include "caf/message.hpp" 16 #include "caf/message_priority.hpp" 17 #include "caf/none.hpp" 18 #include "caf/ref.hpp" 24 template <message_priority Priority,
class... Args>
28 : content_(std::move(
content)), timeout_(timeout) {
44 template <
class Handle,
class RefTag = strong_ref_t>
46 static_assert(is_ref_tag<RefTag>);
47 detail::send_type_check<
none_t, Handle, Args...>();
53 timeout_, make_message_id(Priority),
63 template <message_priority Priority,
class... Args>
75 template <message_priority P = Priority,
76 class E = std::enable_if_t<P == message_priority::normal>>
78 using result_t =
anon_mail_t<message_priority::high, Args...>;
79 return result_t{std::move(content_)};
85 return result_t{std::move(content_), timeout};
92 return result_t{std::move(content_), clock::now() + timeout};
96 template <
class Handle>
97 void send(
const Handle& receiver) && {
98 detail::send_type_check<
none_t, Handle, Args...>();
102 ptr->
enqueue(make_mailbox_element(
nullptr, make_message_id(Priority),
103 std::move(content_)),
112 template <
class... Args>
114 using result_t =
anon_mail_t<message_priority::normal,
115 detail::strip_and_convert_t<Args>...>;
116 return result_t{make_message_nowrap(std::forward<Args>(args)...)};
actor_system & home_system() const noexcept
Returns the system that created this actor (or proxy).
Definition: abstract_actor.cpp:127
Provides a fluent interface for sending anonymous messages to actors.
Definition: anon_mail.hpp:64
std::chrono::steady_clock clock_type
Underlying clock type.
Definition: actor_clock.hpp:22
auto schedule(actor_clock::time_point timeout) &&
Schedules the message for delivery with an absolute timeout.
Definition: anon_mail.hpp:83
Describes a fixed-length, copy-on-write, type-erased tuple with elements of any type.
Definition: message.hpp:32
disposable send(const Handle &receiver, RefTag ref_tag={}) &&
Sends the message to receiver.
Definition: anon_mail.hpp:45
Provides a fluent interface for sending anonymous messages to actors at a specific point in time...
Definition: anon_mail.hpp:25
actor_clock & clock() noexcept
Returns the system-wide clock.
Definition: actor_system.cpp:649
typename clock_type::duration duration_type
Time interval.
Definition: actor_clock.hpp:28
T actor_cast(U &&what)
Converts the actor handle what to a different actor handle or raw pointer of type T...
Definition: actor_cast.hpp:148
typename clock_type::time_point time_point
Discrete point in time.
Definition: actor_clock.hpp:25
auto delay(actor_clock::duration_type timeout) &&
Schedules the message for delivery with a relative timeout.
Definition: anon_mail.hpp:89
Represents "nothing", e.g., for clearing an optional by assigning none.
Definition: none.hpp:14
auto anon_mail(Args &&... args)
Entry point for sending an anonymous message to an actor.
Definition: anon_mail.hpp:113
void send(const Handle &receiver) &&
Sends the message to receiver.
Definition: anon_mail.hpp:97
Base class for all actor implementations.
Definition: abstract_actor.hpp:48
auto urgent() &&
Tags the message as urgent, i.e., sends it with high priority.
Definition: anon_mail.hpp:77
const settings & content(const actor_system_config &cfg)
Returns all user-provided configuration parameters.
Definition: actor_system_config.cpp:594
virtual bool enqueue(mailbox_element_ptr what, scheduler *sched)=0
Enqueues a new message wrapped in a mailbox_element to the actor.
Represents a disposable resource.
Definition: disposable.hpp:15
Root namespace of libcaf.
Definition: custom_types_4.cpp:139
disposable schedule_message(time_point t, strong_actor_ptr receiver, mailbox_element_ptr content)
Schedules an arbitrary message to receiver for time point t.
Definition: actor_clock.cpp:139