pub struct Runtime { /* private fields */ }Expand description
Runtime that owns the main loop for draining updates and rendering.
This is intended to run on the “runtime thread” and should not be invoked from simulation threads.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new(fps: u64) -> Self
pub fn new(fps: u64) -> Self
Create a runtime with a target frames-per-second value.
Examples found in repository?
examples/dummy_project/main.rs (line 30)
17fn main() -> Result<(), Box<dyn std::error::Error>> {
18 let (reporter, mut store) = ClientStore::new();
19
20 let cluster = DummyCluster::new(4);
21 let sim_thread = thread::spawn({
22 let reporter = reporter.clone();
23 move || {
24 cluster.run(20, reporter);
25 }
26 });
27
28 #[cfg(feature = "tui")]
29 {
30 let mut runtime = Runtime::new(20);
31 runtime.run(&mut store)?;
32 }
33
34 let _ = sim_thread.join();
35 Ok(())
36}Sourcepub fn quit_on_q(self, enabled: bool) -> Self
pub fn quit_on_q(self, enabled: bool) -> Self
Control whether pressing q exits the runtime loop.
Sourcepub fn project_label(self, label: impl Into<String>) -> Self
pub fn project_label(self, label: impl Into<String>) -> Self
Set the project label displayed at the top of the UI.
Sourcepub fn run(&mut self, store: &mut ClientStore) -> Result<()>
pub fn run(&mut self, store: &mut ClientStore) -> Result<()>
Run the runtime loop, draining the store and drawing to the terminal.
This method blocks until the loop exits (for example, when q is pressed).
Examples found in repository?
examples/dummy_project/main.rs (line 31)
17fn main() -> Result<(), Box<dyn std::error::Error>> {
18 let (reporter, mut store) = ClientStore::new();
19
20 let cluster = DummyCluster::new(4);
21 let sim_thread = thread::spawn({
22 let reporter = reporter.clone();
23 move || {
24 cluster.run(20, reporter);
25 }
26 });
27
28 #[cfg(feature = "tui")]
29 {
30 let mut runtime = Runtime::new(20);
31 runtime.run(&mut store)?;
32 }
33
34 let _ = sim_thread.join();
35 Ok(())
36}Auto Trait Implementations§
impl Freeze for Runtime
impl RefUnwindSafe for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl UnwindSafe for Runtime
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
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>
Converts
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>
Converts
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