Trait Executor

Source
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§

Source

type Context

Optional Context for adding nodes with specific conditions

Required Methods§

Source

fn start(&mut self)

Starts the nodes contained by the executor

Source

fn update_for_ms(&mut self, ms: u128)

Run the update loop for a set amount of time (in milliseconds)

Source

fn update_loop(&mut self)

Run the update loop until the executor’s interrupt is called

Source

fn check_interrupt(&mut self) -> bool

Check whether the program has been interrupted

Note: This should be called between each Node execution

Source

fn add_node(&mut self, node: Box<dyn Node<ID>>)

Add a node to the executor.

Source

fn remove_node(&mut self, id: &ID) -> Option<Box<dyn Node<ID>>>

Remove a node from the executor.

Provided Methods§

Source

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.

Implementors§