19 #include <type_traits>
27 template<
typename Actor>
28 struct actor_resources;
39 template<
typename Actor>
41 { actor.step() } -> std::convertible_to<bool>;
42 { actor.drain() } -> std::convertible_to<std::size_t>;
43 { actor.empty() } -> std::convertible_to<bool>;
44 { actor.pending_events() } -> std::convertible_to<std::size_t>;
52 template<
typename Actor,
typename Event>
54 { actor.send_event(event) } -> std::convertible_to<bool>;
61 template<
typename Actor,
typename Event>
63 { actor.try_receive(event) } -> std::convertible_to<bool>;
66 template<
typename Event,
typename Sink>
96 return sink_->send_event(event);
107 return sink_->send_event(std::move(event));
128 template<
typename Event,
typename Source>
157 return source_->try_receive(event);
167 template<
typename Event,
typename Sink>
168 [[nodiscard]] constexpr input_port<Event, Sink>
177 template<
typename Event,
typename Source>
188 template<
typename Source,
typename Sink>
190 typename Source::event_type;
191 typename Sink::event_type;
192 requires std::same_as<
typename Source::event_type,
193 typename Sink::event_type>;
194 } &&
requires(Source source, Sink sink,
typename Source::event_type event) {
195 { source.try_receive(event) } -> std::convertible_to<bool>;
196 { sink.try_send(event) } -> std::convertible_to<bool>;
204 template<
typename Source,
typename Sink>
227 if (!sink_->try_send(pending_)) {
230 has_pending_ =
false;
234 if (!source_->try_receive(pending_)) {
238 if (!sink_->try_send(pending_)) {
241 has_pending_ =
false;
258 template<
typename Source,
typename Sink>
265 template<
typename... Links>
270 ((progressed = links.step() || progressed), ...);
285 : actors_(&actors...)
296 [&progressed](
auto*... actor) {
297 ((progressed = actor->step() || progressed), ...);
309 std::size_t rounds{};
319 bool all_empty{
true };
321 [&all_empty](
auto const*... actor) {
322 ((all_empty = all_empty && actor->empty()), ...);
331 std::size_t pending{};
333 [&pending](
auto const*... actor) {
334 ((pending += actor->pending_events()), ...);
341 std::tuple<Actors*...> actors_;
344 template<
typename... Actors>
349 template<
typename Actor,
typename =
void>
350 struct has_runtime_resource_shape : std::false_type
353 template<
typename Actor>
354 struct has_runtime_resource_shape<
356 std::void_t<typename Actor::events, typename Actor::policy>> : std::true_type
359 template<
typename Actor,
typename =
void>
360 struct has_custom_resource_snapshot : std::false_type
363 template<
typename Actor>
364 struct has_custom_resource_snapshot<
366 std::void_t<decltype(Actor::resource_snapshot())>> : std::true_type
392 template<
typename Actor>
403 if constexpr (detail::has_runtime_resource_shape<Actor>::value) {
405 }
else if constexpr (detail::has_custom_resource_snapshot<
414 template<
typename... Actors>
Concepts for runtime queues and dispatch policies.
requires(!has_transition_type_c< T > &&has_transition_member_c< T >) struct transitions_of< T >
Definition: transition.h:479
consteval resource_snapshot add_resource_snapshots(resource_snapshot lhs, resource_snapshot rhs)
Definition: actor.h:371
Definition: freertos.h:26
actor_link(Source &, Sink &) -> actor_link< Source, Sink >
concept actor_source
Definition: actor.h:62
constexpr input_port< Event, Sink > make_input_port(Sink &sink)
Definition: actor.h:169
actor_group(Actors &...) -> actor_group< Actors... >
concept actor_sink
Definition: actor.h:53
bool link_all(Links &... links)
Definition: actor.h:267
concept actor_like
Definition: actor.h:40
constexpr output_port< Event, Source > make_output_port(Source &source)
Definition: actor.h:179
concept compatible_link
Definition: actor.h:189
consteval bool fits(resource_snapshot const &snapshot, resource_budget const &budget)
Definition: resources.h:51
runtime::resource_snapshot resource_snapshot
Definition: runtime.h:131
Static resource accounting for runtimes and task executors.
Aggregate resource summaries for several actor types.
Definition: actor.h:417
static consteval bool fits_within(resource_budget const &budget)
Return whether the aggregate actor resources fit within budget.
Definition: actor.h:429
static consteval resource_snapshot snapshot()
Return the combined resource snapshot for all actor types.
Definition: actor.h:419
std::size_t drain()
Definition: actor.h:307
bool step()
Definition: actor.h:292
bool empty() const
Report whether every actor currently has no pending work.
Definition: actor.h:317
constexpr actor_group(Actors &... actors)
Definition: actor.h:284
std::size_t pending_events() const
Return the sum of each actor's pending-event count.
Definition: actor.h:329
bool pending() const noexcept
Report whether the link is holding one value for retry.
Definition: actor.h:246
constexpr actor_link(Source &source, Sink &sink)
Definition: actor.h:213
bool step()
Definition: actor.h:224
typename Source::event_type event_type
Event type transferred by this link.
Definition: actor.h:208
static consteval resource_snapshot snapshot()
Return the compile-time resource snapshot for Actor.
Definition: actor.h:401
Source source_type
Actor or adapter type referenced by this port.
Definition: actor.h:139
constexpr output_port(Source &source)
Definition: actor.h:145
bool Event
Definition: actor.h:156
Event event_type
Event type produced by this port.
Definition: actor.h:136
bool try_receive(Event &event) const requires actor_source< Source
Definition: resources.h:37
Definition: resources.h:23
std::size_t max_event_bytes
Definition: resources.h:24
std::size_t delayed_event_timer_slots
Definition: resources.h:27
std::size_t task_timer_slots
Definition: resources.h:32
std::size_t task_arena_bytes
Definition: resources.h:31
std::size_t max_event_alignment
Definition: resources.h:25
bool uses_heap
Definition: resources.h:33
std::size_t queue_slots
Definition: resources.h:26
std::size_t task_group_entry_count
Definition: resources.h:30
std::size_t task_count
Definition: resources.h:28
std::size_t task_group_count
Definition: resources.h:29
static consteval resource_snapshot snapshot()
Definition: resources.h:118