xronos-sdk 0.2.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 ()
 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.
 

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.

Constructor & Destructor Documentation

◆ Environment()

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.

Member Function Documentation

◆ execute()

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.

◆ request_shutdown()

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.

◆ context()

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

Get the top-level initialization context object.

This is needed in order to instantiate top-level reactors.

◆ connect() [1/6]

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 communicated by the connection are delivered with no delay.

Template Parameters
TThe type communicated by the connection.
Parameters
fromThe port to draw the connection from
toThe port to draw the connection to.

◆ connect() [2/6]

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

◆ connect() [3/6]

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

◆ connect() [4/6]

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.

Template Parameters
TThe type communicated by the connection.
Parameters
fromThe port to draw the connection from
toThe port to draw the connection to.
delayThe connection waits for delay before delivering the messages to to.

◆ connect() [5/6]

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

◆ connect() [6/6]

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

◆ enable_tracing()

void xronos::sdk::Environment::enable_tracing ( std::string_view application_name = "xronos",
std::string_view endpoint = "localhost:4317" )

Enable tracing for the environment.

Parameters
application_nameThe name of the current application.
endpointThe endpoint to which the traces should be sent. This should be a URI of the form http://host:port or https://host:port.

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