The entry point for assembling and executing applications. More...
#include <xronos/sdk/environment.hh>
Public Member Functions | |
| Environment () | |
| Constructor. | |
| ~Environment ()=default | |
| Destructor. | |
| template<class T, template< class > class FromSerializer, template< class > class ToSerializer> requires std::is_same_v<FromSerializer<T>, NoSerializer<T>> || std::is_same_v<ToSerializer<T>, NoSerializer<T>> || std::is_same_v <FromSerializer<T>, ToSerializer<T>> | |
| void | connect (const InputPort< T, FromSerializer > &from, const InputPort< T, ToSerializer > &to) |
| Connect two ports. | |
| template<class T, template< class > class FromSerializer, template< class > class ToSerializer> requires std::is_same_v<FromSerializer<T>, NoSerializer<T>> || std::is_same_v<ToSerializer<T>, NoSerializer<T>> || std::is_same_v <FromSerializer<T>, ToSerializer<T>> | |
| void | connect (const InputPort< T, FromSerializer > &from, const InputPort< T, ToSerializer > &to, Duration delay) |
| Connect two ports with a delay. | |
|
template<class T, template< class > class FromSerializer, template< class > class ToSerializer> requires std::is_same_v<FromSerializer<T>, NoSerializer<T>> || std::is_same_v<ToSerializer<T>, NoSerializer<T>> || std::is_same_v <FromSerializer<T>, ToSerializer<T>> | |
| void | connect (const OutputPort< T, FromSerializer > &from, const InputPort< T, ToSerializer > &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, template< class > class FromSerializer, template< class > class ToSerializer> requires std::is_same_v<FromSerializer<T>, NoSerializer<T>> || std::is_same_v<ToSerializer<T>, NoSerializer<T>> || std::is_same_v <FromSerializer<T>, ToSerializer<T>> | |
| void | connect (const OutputPort< T, FromSerializer > &from, const InputPort< T, ToSerializer > &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, template< class > class FromSerializer, template< class > class ToSerializer> requires std::is_same_v<FromSerializer<T>, NoSerializer<T>> || std::is_same_v<ToSerializer<T>, NoSerializer<T>> || std::is_same_v <FromSerializer<T>, ToSerializer<T>> | |
| void | connect (const OutputPort< T, FromSerializer > &from, const OutputPort< T, ToSerializer > &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, template< class > class FromSerializer, template< class > class ToSerializer> requires std::is_same_v<FromSerializer<T>, NoSerializer<T>> || std::is_same_v<ToSerializer<T>, NoSerializer<T>> || std::is_same_v <FromSerializer<T>, ToSerializer<T>> | |
| void | connect (const OutputPort< T, FromSerializer > &from, const OutputPort< T, ToSerializer > &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. | |
| auto | context (std::source_location source_location=std::source_location::current()) noexcept -> EnvironmentContext |
| Get a context object for constructing top-level reactors. | |
| void | enable_telemetry (std::string_view application_name="xronos", std::string_view endpoint="localhost:4317") |
| Enable collecting and sending telemetry data from the application. | |
| void | execute () |
| Execute the application. | |
| void | execute (const RuntimeProvider &runtime_provider) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
The entry point for assembling and executing applications.
The environment creates and contains top-level reactors, connects them, and executes the application.
| void xronos::sdk::Environment::connect | ( | const InputPort< T, FromSerializer > & | from, |
| const InputPort< T, ToSerializer > & | 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.
A port may feed several connections but receives through at most one. The environment connects only ports of top-level reactors.
| T | Value type associated with messages relayed by the connection. |
| from | The port to connect from. |
| to | The port to connect to. |
| void xronos::sdk::Environment::connect | ( | const InputPort< T, FromSerializer > & | from, |
| const InputPort< T, ToSerializer > & | 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.
A port may feed several connections but receives through at most one. The environment connects only ports of top-level reactors.
| T | Value type associated with messages relayed by the connection. |
| from | The port to connect from. |
| to | The port to connect to. |
| delay | The delay to apply to all messages. |
|
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::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 4317 on the host running the Dashboard. |
| void xronos::sdk::Environment::execute | ( | ) |
Execute the application.
Initiates the execution of an application. This first assembles the application by calling Reactor::assemble() on each reactor. The runtime then begins execution, and every Startup event source emits an event.
Returns when the application terminates. The application terminates when there are no more events, after calling ShutdownEffect::trigger_shutdown(), or when it reaches the timeout configured on the environment.
An exception thrown by a reaction handler also terminates the application. The runtime then stops invoking reaction handlers; a handler that is about to start may still run. Shutdown reactions run in any case, and execute() rethrows the first exception.
The application executes on the default runtime. To select a different runtime, use the overload that takes a RuntimeProvider.
| void xronos::sdk::Environment::execute | ( | const RuntimeProvider & | runtime_provider | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| runtime_provider | Provider of the runtime that should be used for execution. |