Skip to main content

StageExecutor.h File

Actor-like stage executor interface — the runtime-graph extension point. More...

Included Headers

#include "graph/GraphTypes.h" #include "pipeline/SessionOptions.h" #include <cstdint> #include <string> #include <unordered_map> #include <vector>

Namespaces Index

namespacesimaai
namespaceneat
namespacegraph

Classes Index

structStageMsg

A single input message handed to a StageExecutor. More...

structStageOutMsg

A single output message produced by a StageExecutor. More...

classStageEmitter

Runtime-owned output handle for stages that stream while on_input() is active. More...

structStagePorts

Resolved port-id table for a stage — populated by the runtime before start(). More...

classStageExecutor

Actor-style executor base class — implement to add a new runtime-graph stage. More...

Description

Actor-like stage executor interface — the runtime-graph extension point.

StageExecutor is to the runtime graph what Node is to the builder graph: the abstract base every stage subclasses. The runtime drives stages by calling on_input() for each arriving sample and on_tick() periodically; the stage emits zero or more StageOutMsgs back to the runtime, which routes them on outgoing edges.

See Also

Graph, GraphSession, GraphRun

See Also

"Runtime graph stages" (§73 / §84 of the design deep dive)

File Listing

The file content with the documentation metadata removed is:

1
14#pragma once
15
16#include "graph/GraphTypes.h"
18
19#include <cstdint>
20#include <string>
21#include <unordered_map>
22#include <vector>
23
24namespace simaai::neat::graph {
25
33struct StageMsg {
34 PortId in_port = kInvalidPort;
36};
37
44struct StageOutMsg {
45 PortId out_port = kInvalidPort;
47};
48
60public:
61 virtual ~StageEmitter() = default;
62
64 virtual bool emit(StageOutMsg msg) = 0;
66 virtual bool stop_requested() const = 0;
67};
68
76struct StagePorts {
77 std::unordered_map<std::string, PortId> in;
78 std::unordered_map<std::string, PortId> out;
79
81 PortId in_port(const std::string& name) const {
82 auto it = in.find(name);
83 return it == in.end() ? kInvalidPort : it->second;
84 }
85
87 PortId out_port(const std::string& name) const {
88 auto it = out.find(name);
89 return it == out.end() ? kInvalidPort : it->second;
90 }
91
93 PortId only_input() const {
94 return in.size() == 1 ? in.begin()->second : kInvalidPort;
95 }
96
99 return out.size() == 1 ? out.begin()->second : kInvalidPort;
100 }
101};
102
120public:
122 virtual ~StageExecutor() = default;
123
125 virtual void set_ports(const StagePorts& /*ports*/) {}
126
128 virtual void set_emitter(StageEmitter* /*emitter*/) {}
129
131 virtual void start() {}
133 virtual void request_stop() {}
135 virtual void stop() {}
136
142 virtual void on_input(StageMsg&& msg, std::vector<StageOutMsg>& out) = 0;
143
150 virtual void on_tick(std::int64_t /*now_ns*/, std::vector<StageOutMsg>& /*out*/) {}
151};
152
153} // namespace simaai::neat::graph

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.