Skip to main content

RtHandle

Struct RtHandle 

Source
pub struct RtHandle { /* private fields */ }
Available on crate feature distributed only.
Expand description

A real-time handle to a Graph that can be atomically swapped without stopping the RT thread.

Wrap a compiled Graph in an RtHandle; the RT thread drives cycles via RtHandle::process_cycle, and the control thread publishes replacements via RtHandle::install.

§Example

let handle = RtHandle::new(compiled_graph);

// RT thread:
let mut ctx = ProcessContext::new(256, 0, 48_000);
handle.process_cycle(&mut ctx).unwrap();

// Control thread — publish a freshly-built graph without stopping RT:
let new_graph: Graph = { /* ...rebuild + recompile... */ Graph::new() };
handle.install(new_graph);

Implementations§

Source§

impl RtHandle

Source

pub fn new(graph: Graph) -> Self

Creates a handle owning graph (typically already compiled).

Source

pub fn install(&self, graph: Graph)

Atomically publishes a new graph. Control thread only.

The previously-installed graph is dropped once no RT cycle holds a guard to it (epoch-based reclamation via arc-swap).

Source

pub fn process_cycle(&self, ctx: &mut ProcessContext) -> Result<(), GraphError>

Loads the current graph and runs one RT cycle.

Wait-free load (arc-swap); the graph’s Graph::process_cycle is allocation-free. Returns GraphError::NotCompiled if the loaded graph was never compiled.

§Errors

Propagates GraphError from Graph::process_cycle.

Source

pub fn graph(&self) -> Guard<Arc<Graph>>

Loads the current graph (wait-free) and returns a guard to it.

Use for diagnostics or to call read-only &self accessors on the installed graph (e.g. Graph::read_output) after a cycle. The guard keeps the graph alive for the duration of the borrow.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.