Crate reactor_rt

Source
Expand description

The runtime library for reactor programs generated by LFC, the Lingua Franca compiler.

Most of this crate consists of types that are manipulated only by the generated code. User-written Rust code mostly interacts with the type ReactionCtx, which is the entry point for user documentation.

Crate-level features include:

  • parallel-runtime: use Rayon to execute reactions in parallel when possible. This is not yet the default. For some applications, where there is no data parallelism, this may harm performance (as well as pull in unneeded dependencies) and should be off.
  • wide-ids: Enables 64-bit wide reaction ids on 64-bit architectures. This may reduce performance, but allows for 2^32 reactor instances compared to the default of 2^16, which may feel a bit tight for some applications. On machines with a pointer-width of less than 64 bits, ID types are always 32 bits. The feature also widens trigger ids to 64 bits if possible, which enables 2^64 individual trigger components (ports, actions, etc.) instead of 2^32.
  • vec-id-sets: Change the implementation of reaction sets to be a sorted vector instead of a hash set. This has a positive performance impact, as reaction sets are typically very small. More testing is required to determine pathological cases. This is a default feature.
  • no-unsafe: disable optimisations that use unsafe code in this runtime. Just provided for comparison, should probably be removed (unsafe code is fine).

Modules§

assembly
Module containing the API to initialize a reactor program.
prelude
The prelude that is imported at the top of reactor files generated by LFC.

Macros§

after
Shorthand for using After together with delay.
assert_tag_is
Convenient macro to assert equality of the current tag. This is just shorthand for using assert_eq! with the syntax of tag.
delay
Creates a Duration value using the same syntax as in LF.
tag
Convenient macro to create a tag. This is just a shorthand for using the constructor together with the syntax of delay.

Structs§

AsyncCtx
A type that can affect the logical event queue to implement asynchronous physical actions. This is a “link” to the event system, from the outside world.
Duration
A Duration type to represent a span of time, typically used for system timeouts.
EventTag
The tag of an event.
GlobalReactionId
Global identifier for a reaction.
Instant
A measurement of a monotonically nondecreasing clock. Opaque and useful only with Duration.
LocalReactionId
ID of a reaction local to its containing reactor.
LogicalAction
A logical action.
MicroStep
Type of the microsteps of an EventTag.
Multiport
A multiport is a vector of independent ports (its channels) Multiports have special Lingua Franca syntax, similar to reactor banks.
PhysicalAction
A physical action. Physical actions may only be used with the API of AsyncCtx. See ReactionCtx::spawn_physical_thread.
PhysicalActionRef
A reference to a physical action. This thing is cloneable and can be sent to async threads. The contained action reference is unique and protected by a lock. All operations on the action are
Port
Represents a port, which carries values of type T. Ports reify the data inputs and outputs of a reactor.
ReactionCtx
The context in which a reaction executes. Its API allows mutating the event queue of the scheduler. Only the interactions declared at assembly time are allowed.
ReactorId
The unique identifier of a reactor instance during execution.
SchedulerOptions
Construction parameters for the scheduler.
SyncScheduler
The runtime scheduler.
Timer
A timer is conceptually a logical action that may re-schedule itself periodically.

Enums§

Offset
An offset from the current event.
TimeUnit
A unit of time, used in LF.

Traits§

ReactionTrigger
Common trait for actions, ports, and timer objects handed to reaction functions. This is meant to be used through the API of ReactionCtx instead of directly.
ReactorBehavior
The trait used by the framework to interact with the reactor during runtime.
SchedulableAsAction
Implemented by LogicalAction and PhysicalAction references to give access to ReactionCtx::schedule and variants.

Functions§

try_parse_duration
Parse a duration from a string. This is used for CLI parameter parsing in programs generated by LFC, specifically, to parse main parameters with time type, and scheduler options with time type.