pub struct Executor { /* private fields */ }Expand description
The deterministic single-threaded executor.
One instance is created per simulation iteration, seeded from the iteration seed; dropping it cancels every task that is still alive (see the module docs for the kill-on-drop mechanics).
§Examples
let mut executor = moonpool_sim::executor::Executor::new(42);
let sum = executor.block_on(async {
let task = moonpool_sim::executor::spawn("adder", async { 1 + 2 });
task.await.expect("task completed")
});
assert_eq!(sum, 3);Implementations§
Source§impl Executor
impl Executor
Sourcepub fn block_on<F: Future>(&mut self, main: F) -> F::Output
pub fn block_on<F: Future>(&mut self, main: F) -> F::Output
Run main as the driver future to completion, interleaving it with
the task pool (see the module docs for the drive loop).
main needs no Send bound: it is pinned on this stack and never
enters the ready queue.
§Panics
- if called while another
block_onis running on this thread; - on a genuine deadlock: the driver is not woken, returns
Pending, and no task is runnable (with the seed in the message, replacing tokio’s silent forever-park).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Executor
impl !UnwindSafe for Executor
impl Freeze for Executor
impl Send for Executor
impl Sync for Executor
impl Unpin for Executor
impl UnsafeUnpin for Executor
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