Define language settings in the language crate

This commit is contained in:
Max Brunsfeld 2023-05-11 14:40:35 -07:00
parent 9ae10a5dd9
commit 39618ae32d
54 changed files with 1348 additions and 1161 deletions

View file

@ -477,6 +477,14 @@ impl Deterministic {
state.rng = StdRng::seed_from_u64(state.seed);
}
pub fn allow_parking(&self) {
use rand::prelude::*;
let mut state = self.state.lock();
state.forbid_parking = false;
state.rng = StdRng::seed_from_u64(state.seed);
}
pub async fn simulate_random_delay(&self) {
use rand::prelude::*;
use smol::future::yield_now;
@ -698,6 +706,14 @@ impl Foreground {
}
}
#[cfg(any(test, feature = "test-support"))]
pub fn allow_parking(&self) {
match self {
Self::Deterministic { executor, .. } => executor.allow_parking(),
_ => panic!("this method can only be called on a deterministic executor"),
}
}
#[cfg(any(test, feature = "test-support"))]
pub fn advance_clock(&self, duration: Duration) {
match self {