pub struct Parallelizer<M = ()> { /* private fields */ }Expand description
Parallelizer runs all its states at the same time.
Note that at any time you ask it to make a decision it goes through non-active states and tries to run them so instead of starting all possible states at once, it will ensure that at any time of decision making all possible states will run.
§Example
use emergent::prelude::*;
struct Memory {
a: bool,
b: bool,
}
let mut parallelizer = Parallelizer::new(vec![
ParallelizerState::new(true, ClosureTask::default().enter(|m: &mut Memory| m.a = true)),
ParallelizerState::new(true, ClosureTask::default().enter(|m: &mut Memory| m.b = true)),
]);
let mut memory = Memory { a: false, b: false };
assert!(parallelizer.process(&mut memory));
assert_eq!(memory.a, true);
assert_eq!(memory.b, true);Implementations§
Source§impl<M> Parallelizer<M>
impl<M> Parallelizer<M>
Trait Implementations§
Source§impl<M> Debug for Parallelizer<M>
impl<M> Debug for Parallelizer<M>
Source§impl<M, K> DecisionMaker<M, K> for Parallelizer<M>where
K: Default,
impl<M, K> DecisionMaker<M, K> for Parallelizer<M>where
K: Default,
Source§impl<M> Task<M> for Parallelizer<M>
impl<M> Task<M> for Parallelizer<M>
Source§fn is_locked(&self, memory: &M) -> bool
fn is_locked(&self, memory: &M) -> bool
Tells if task is locked (it’s still running). Used by decision makers to tell if one can
change its state (when current task is not locked).
Source§fn on_update(&mut self, memory: &mut M)
fn on_update(&mut self, memory: &mut M)
Action performed when task is active and gets updated.
Source§fn on_process(&mut self, memory: &mut M) -> bool
fn on_process(&mut self, memory: &mut M) -> bool
Action performed when task is active but decision maker did not changed its state.
This one is applicable for making hierarchical decision makers (telling children decision
makers to decide on new state, because some if not all decision makers are tasks). Read more
Auto Trait Implementations§
impl<M> Freeze for Parallelizer<M>
impl<M = ()> !RefUnwindSafe for Parallelizer<M>
impl<M> Send for Parallelizer<M>
impl<M> Sync for Parallelizer<M>
impl<M> Unpin for Parallelizer<M>
impl<M = ()> !UnwindSafe for Parallelizer<M>
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
Mutably borrows from an owned value. Read more