The entry point for assembling and executing reactor programs. More...
#include <xronos/sdk/environment.hh>
Public Member Functions | |
Environment () | |
Construct a new Environment object. | |
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 the top-level initialization context object. | |
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) |
template<class T> | |
void | connect (const OutputPort< T > &from, const InputPort< T > &to) |
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) |
template<class T> | |
void | connect (const OutputPort< T > &from, const InputPort< T > &to, Duration delay) |
void | enable_tracing (std::string_view application_name="xronos", std::string_view endpoint="localhost:4317") |
Enable tracing for the environment. | |
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.
xronos::sdk::Environment::Environment | ( | ) |
Construct a new Environment object.
Programs that use this environment will execute indefinitely or until a shutdown is requested, and will run with the closest possible approximation to real time.
void xronos::sdk::Environment::execute | ( | ) |
Execute the reactor program.
Initiates the execution of a reactor program. This triggers xronos::sdk::Startup
and instructs the runtime to start processing reactions.
Returns when the reactor program terminates.
void xronos::sdk::Environment::request_shutdown | ( | ) |
Request the termination of a currently running reactor program.
Terminates a program started with execute
at the next convenience. This triggers xronos::sdk::Shutdown
after completing all currently active reactions, and stops program execution after processing all reactions triggered by xronos::sdk::Shutdown
.
|
nodiscardnoexcept |
Get the top-level initialization context object.
This is needed in order to instantiate top-level reactors.
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 communicated by the connection are delivered with no delay.
T | The type communicated 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 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.
void xronos::sdk::Environment::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.
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
.
T | The type communicated by the connection. |
from | The port to draw the connection from |
to | The port to draw the connection to. |
delay | The connection waits for delay before delivering the messages to to . |
void xronos::sdk::Environment::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.
void xronos::sdk::Environment::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 xronos::sdk::Environment::enable_tracing | ( | std::string_view | application_name = "xronos", |
std::string_view | endpoint = "localhost:4317" ) |
Enable tracing for the environment.
application_name | The name of the current application. |
endpoint | The endpoint to which the traces should be sent. This should be a URI of the form http://host:port or https://host:port . |