Struct knyst::controller::Controller
source · pub struct Controller { /* private fields */ }
Expand description
Receives commands from one or several KnystCommands
that may be on
different threads, and applies those to a top level Graph
.
Implementations§
source§impl Controller
impl Controller
sourcepub fn new(
top_level_graph: Graph,
error_handler: impl FnMut(KnystError) + Send + 'static,
resources_sender: Producer<ResourcesCommand>,
resources_receiver: Consumer<ResourcesResponse>
) -> Self
pub fn new( top_level_graph: Graph, error_handler: impl FnMut(KnystError) + Send + 'static, resources_sender: Producer<ResourcesCommand>, resources_receiver: Consumer<ResourcesResponse> ) -> Self
Creates a new Controller
taking the top level Graph
to which
commands will be applied and an error handler. You almost never want to
call this in program code; the AudioBackend will create one for you.
sourcepub fn run(&mut self, max_commands_before_update: usize) -> bool
pub fn run(&mut self, max_commands_before_update: usize) -> bool
Receives messages, applies them and then runs maintenance. Maintenance
includes updating the Graph
, sending the changes made to the
audio thread.
max_commands_before_update
is the maximum number of commands read from
the queue before forcing maintenance. If you are sending a lot of
commands, fine tuning this can probably reduce latency.
Returns true if all commands in the queue were processed.
sourcepub fn get_knyst_commands(&self) -> MultiThreadedKnystCommands
pub fn get_knyst_commands(&self) -> MultiThreadedKnystCommands
Create a KnystCommands
that can communicate with Self
sourcepub fn start_on_new_thread(self) -> MultiThreadedKnystCommands
pub fn start_on_new_thread(self) -> MultiThreadedKnystCommands
Consumes the Controller
and moves it to a new thread where it will run
in a loop.
Auto Trait Implementations§
impl !RefUnwindSafe for Controller
impl Send for Controller
impl !Sync for Controller
impl Unpin for Controller
impl !UnwindSafe for Controller
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.