pub struct SimThread { /* private fields */ }Expand description
Handle on a running CPU simulation.
The sim runs on its own thread on native targets. In a browser Self::update steps it from the host’s
frame loop.
Implementations§
Source§impl SimThread
impl SimThread
Sourcepub fn new(
state: Box<dyn SimState>,
target_tps: f64,
wake: Option<WakeFn>,
faults: FaultSink,
) -> Self
pub fn new( state: Box<dyn SimState>, target_tps: f64, wake: Option<WakeFn>, faults: FaultSink, ) -> Self
Starts a paused runner over state, capped at target_tps ticks per second.
wake is None only for a headless caller that polls on its own schedule.
A panic out of the loop is stored in faults. The GPU runner reads the same sink off its GpuContext.
Sourcepub fn send(&mut self, cmd: SimCommand)
pub fn send(&mut self, cmd: SimCommand)
Sends a command to the loop.
Sourcepub fn take_snapshot(&mut self) -> Option<Snapshot>
pub fn take_snapshot(&mut self) -> Option<Snapshot>
Takes the latest snapshot, or None when nothing new has been published since the last take.
Sourcepub fn recycle(&mut self, snap: Snapshot)
pub fn recycle(&mut self, snap: Snapshot)
Stores a taken snapshot as the spare for the next publish to refill.
This is only an optimisation. Dropping the snapshot instead only means the next publish allocates.
Sourcepub fn play(&mut self)
pub fn play(&mut self)
Sends SimCommand::Play.
Sourcepub fn pause(&mut self)
pub fn pause(&mut self)
Sends SimCommand::Pause.
Sourcepub fn step_once(&mut self)
pub fn step_once(&mut self)
Sends SimCommand::StepOnce.
Sourcepub fn set_schedule(&mut self, schedule: Schedule)
pub fn set_schedule(&mut self, schedule: Schedule)
Sends SimCommand::SetSchedule.
Sourcepub fn run_to(&mut self, tick: u64)
pub fn run_to(&mut self, tick: u64)
Sends SimCommand::RunTo.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SimThread
impl !UnwindSafe for SimThread
impl Freeze for SimThread
impl Send for SimThread
impl Sync for SimThread
impl Unpin for SimThread
impl UnsafeUnpin for SimThread
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more