Struct netsblox_vm::project::IdleAction
source · pub struct IdleAction { /* private fields */ }Expand description
A state machine that performs an action during idle periods.
This could be used to invoke std::thread::sleep during idle periods to save CPU time.
Implementations§
source§impl IdleAction
impl IdleAction
sourcepub fn new(thresh: usize, action: Box<dyn FnMut()>) -> Self
pub fn new(thresh: usize, action: Box<dyn FnMut()>) -> Self
Creates a new IdleAction that triggers automatically after max_yields idle steps.
sourcepub fn consume<C: CustomTypes<S>, S: System<C>>(
&mut self,
res: &ProjectStep<'_, C, S>
)
pub fn consume<C: CustomTypes<S>, S: System<C>>( &mut self, res: &ProjectStep<'_, C, S> )
Consumes a step result and advances the state machine. If the step resulting in an idle action, this may trigger the idle action to fire and reset the state machine.
Auto Trait Implementations§
impl !RefUnwindSafe for IdleAction
impl !Send for IdleAction
impl !Sync for IdleAction
impl Unpin for IdleAction
impl !UnwindSafe for IdleAction
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