xronos-sdk 0.5.0
Xronos C++ SDK
Loading...
Searching...
No Matches
xronos::sdk::Environment Class Reference

The entry point for assembling and executing reactor programs. More...

#include <xronos/sdk/environment.hh>

Inheritance diagram for xronos::sdk::Environment:
[legend]

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.

Detailed Description

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.

Member Function Documentation

◆ execute()

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().

◆ request_shutdown()

void xronos::sdk::Environment::request_shutdown ( )

Request the termination of a currently running reactor program.

Terminates a running program at the next convenience. After completing all currently active reactions, this triggers the Shutdown event sources. Once all reactions triggered by Shutdown are processed, the program terminates.

◆ context()

auto xronos::sdk::Environment::context ( std::source_location source_location = std::source_location::current()) -> EnvironmentContext
nodiscardnoexcept

Get a context object for constructing top-level reactors.

Parameters
source_locationSource location of the call site. Normally this should be omitted to use the default argument.
Returns
This environment's context.

◆ connect() [1/2]

template<class T>
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.

Template Parameters
TValue type associated with events relayed by the connection.
Parameters
fromThe port to draw the connection from
toThe port to draw the connection to.

◆ connect() [2/2]

template<class T>
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.

Template Parameters
TValue type associated with events relayed by the connection.
Parameters
fromThe port to draw the connection from
toThe port to draw the connection to.
delayThe delay to apply to all messages.

◆ enable_telemetry()

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.

Parameters
application_nameThe name of the application as it should appear in the telemetry metadata.
endpointThe network endpoint to send telemetry data to. This is typically port 4137 on the host running the Dashboard.

The documentation for this class was generated from the following file: