pub struct Runtime { /* private fields */ }Expand description
Handle to the running RT thread.
Owns the join handle for the spawned thread. Dropping the Runtime
signals shutdown and joins the thread. Use Runtime::start to
create one.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn start(config: RuntimeConfig) -> Result<(Self, RtHandles), Error>
pub fn start(config: RuntimeConfig) -> Result<(Self, RtHandles), Error>
Spawns the RT thread with the given configuration.
Blocks until the thread has elevated its priority and opened all
MIDI ports. Returns a Runtime handle (for lifecycle management)
and RtHandles (for queue communication with the ECS world).
§Errors
Returns Error::MidiInit if MIDI ports cannot be opened,
Error::PortNotFound if a configured port name has no match,
or Error::PriorityElevation if RT priority cannot be obtained
and RuntimeConfig::allow_normal_priority is false.
Sourcepub fn stop(&mut self) -> Result<(), Error>
pub fn stop(&mut self) -> Result<(), Error>
Gracefully shuts down the RT thread.
Sets the shutdown flag and joins the thread. This is also called
automatically on Drop.
§Errors
Returns Error::AlreadyStopped if the runtime was already
shut down, or Error::ThreadPanicked if the thread panicked.