pub trait Executor<ID: PartialEq> {
type Context;
// Required methods
fn start(&mut self);
fn update_for_ms(&mut self, ms: u128);
fn update_loop(&mut self);
fn check_interrupt(&mut self) -> bool;
fn add_node(&mut self, node: Box<dyn Node<ID>>);
fn remove_node(&mut self, id: &ID) -> Option<Box<dyn Node<ID>>>;
// Provided method
fn add_node_with_context(
&mut self,
node: Box<dyn Node<ID>>,
_ctx: Self::Context,
) { ... }
}
Expand description
An executor handles the scheduling and execution of nodes
All nodes should have some unique ID that makes them identifiable as trait objects
Required Associated Types§
Required Methods§
Sourcefn update_for_ms(&mut self, ms: u128)
fn update_for_ms(&mut self, ms: u128)
Run the update loop for a set amount of time (in milliseconds)
Sourcefn update_loop(&mut self)
fn update_loop(&mut self)
Run the update loop until the executor’s interrupt is called
Sourcefn check_interrupt(&mut self) -> bool
fn check_interrupt(&mut self) -> bool
Check whether the program has been interrupted
Note: This should be called between each Node execution
Provided Methods§
Sourcefn add_node_with_context(
&mut self,
node: Box<dyn Node<ID>>,
_ctx: Self::Context,
)
fn add_node_with_context( &mut self, node: Box<dyn Node<ID>>, _ctx: Self::Context, )
Add a node to the executor with some given context.
Note: The context is mainly to allow for extra configuration when adding nodes.