The entry point for assembling and executing reactor programs. More...
#include <xronos/sdk/environment.hh>
Public Member Functions | |
Environment () | |
Constructor. | |
~Environment () | |
Destructor. | |
void | execute () |
Execute the reactor program. | |
void | request_shutdown () |
Request the termination of a currently running reactor program. | |
auto | context (std::source_location source_location=std::source_location::current()) noexcept -> EnvironmentContext |
Get a context object for constructing top-level reactors. | |
template<class T> | |
void | connect (const InputPort< T > &from, const InputPort< T > &to) |
Connect two ports. | |
template<class T> | |
void | connect (const OutputPort< T > &from, const OutputPort< T > &to) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<class T> | |
void | connect (const OutputPort< T > &from, const InputPort< T > &to) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<class T> | |
void | connect (const InputPort< T > &from, const InputPort< T > &to, Duration delay) |
Connect two ports with a delay. | |
template<class T> | |
void | connect (const OutputPort< T > &from, const OutputPort< T > &to, Duration delay) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<class T> | |
void | connect (const OutputPort< T > &from, const InputPort< T > &to, Duration delay) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | enable_telemetry (std::string_view application_name="xronos", std::string_view endpoint="localhost:4317") |
Enable collecting and sending telemetry data from the application. |
The entry point for assembling and executing reactor programs.
The environment acts as an execution context for reactor programs. It manages both the creation of reactors and the execution of reactor programs.
void xronos::sdk::Environment::execute | ( | ) |
Execute the reactor program.
Initiates the execution of a reactor program. This first assembles the reactor program by calling Reactor::assemble() on each reactor and then initiates execution by triggering all Startup event sources.
Returns when the reactor program terminates. The reactor program terminates when there are no more events, or after calling request_shutdown().
void xronos::sdk::Environment::request_shutdown | ( | ) |
|
nodiscardnoexcept |
Get a context object for constructing top-level reactors.
source_location | Source location of the call site. Normally this should be omitted to use the default argument. |
void xronos::sdk::Environment::connect | ( | const InputPort< T > & | from, |
const InputPort< T > & | to ) |
Connect two ports.
Creates a new connection from the port given in from
to the port given in to
. Messages are delivered without a delay. This means that the timestamp at which the message is received is the same as the timestamp at which it was sent.
T | Value type associated with events relayed by the connection. |
from | The port to draw the connection from |
to | The port to draw the connection to. |
void xronos::sdk::Environment::connect | ( | const InputPort< T > & | from, |
const InputPort< T > & | to, | ||
Duration | delay ) |
Connect two ports with a delay.
Creates a new connection from the port given in from
to the port given in to
. Messages are delivered with a delay. This means that the timestamp at which the message is received is the timestamp at which it was sent plus delay
.
T | Value type associated with events relayed by the connection. |
from | The port to draw the connection from |
to | The port to draw the connection to. |
delay | The delay to apply to all messages. |
void xronos::sdk::Environment::enable_telemetry | ( | std::string_view | application_name = "xronos", |
std::string_view | endpoint = "localhost:4317" ) |
Enable collecting and sending telemetry data from the application.
See Telemetry and Dashboard for more information on producing, collecting and visualizing telemetry data.
application_name | The name of the application as it should appear in the telemetry metadata. |
endpoint | The network endpoint to send telemetry data to. This is typically port 4137 on the host running the Dashboard. |