Skip to main content

Runtime

Struct Runtime 

Source
pub struct Runtime { /* private fields */ }
Expand description

Owns one simulation’s host from source binding through execution.

Install Self::host in dive_model::BindOptions before binding, then execute with this same runtime. Startup and reached random operations share one stream; the simulator never restarts a caller’s partially consumed RNG. A runtime admits one execution, including failed/cancelled executions. Run execution on a thread with dive_eval::RECOMMENDED_STACK.

use dive_sim::{Options, Runtime};
use dive_stdlib::random::RandomMode;
let runtime = Runtime::new(Options::new(7, RandomMode::Dive, 100, 10));
let binding = dive_model::BindOptions { host: Some(runtime.host()), ..Default::default() };
assert!(binding.host.is_some());
// Bind the source with `binding`, then run a backend with
// `runtime.simulate_with_backend`.

Implementations§

Source§

impl Runtime

Source

pub fn new(options: Options) -> Self

Creates the run context before source binding or startup evaluation.

Source

pub fn host(&self) -> Arc<dyn Host> ⓘ

The owned host to install in the source binder.

Source

pub fn set_config(&self, config: Option<RunConfig>)

Supplies the actual bound configuration after startup binding finishes. Configuration remains unavailable during binding, as in ordinary TLC.

Source

pub fn simulate_with_backend( &self, model: &Model, driver: impl FnOnce(&dyn Fn() -> (usize, usize)) -> Report, ) -> Report

Runs an alternate finite backend under this same binding/runtime host. The callback receives the remaining retained-output allowance.

Trait Implementations§

Source§

impl Debug for Runtime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.