Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ members = ["examples/*"]
[dependencies]
bytes = "1.4"
indexmap = "2"
rand = { version = "0.8.5", features = ["small_rng"] }
rand_distr = "0.4.3"
rand = "0.9"
rand_distr = "0.5"
regex = { version = "1", optional = true }
scoped-tls = "1.0.1"
tokio = { version = "1.25.0", features = ["full", "test-util"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/cluster/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ turmoil = { path = "../.." }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing = "0.1"
tokio = "1"
rand = "0.8"
rand = "0.9"
getrandom = "0.3"
4 changes: 2 additions & 2 deletions examples/cluster/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
time::Duration,
};

use rand::{rngs::SmallRng, seq::SliceRandom, Rng, SeedableRng};
use rand::{rngs::SmallRng, seq::IndexedRandom, Rng, SeedableRng};
use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
task::JoinSet,
Expand Down Expand Up @@ -257,7 +257,7 @@ impl Client {
attempt += 1;

let backoff = std::cmp::max(init_backoff * 2u64.pow(attempt), 3600);
let jitter = self.cluster.rng().gen_range(0..backoff);
let jitter = self.cluster.rng().random_range(0..backoff);

tokio::time::sleep(Duration::from_millis(jitter)).await;
}
Expand Down
2 changes: 1 addition & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Builder {

let rng = match self.rng_seed {
Some(seed) => SmallRng::seed_from_u64(seed),
None => SmallRng::from_entropy(),
None => SmallRng::from_os_rng(),
};

let world = World::new(
Expand Down
2 changes: 1 addition & 1 deletion src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fn init(config: &mut Config) -> (Runtime, LocalSet) {

#[cfg(tokio_unstable)]
if let Some(rng) = &mut config.rng {
let bytes: [u8; 32] = rand::Rng::gen(rng);
let bytes: [u8; 32] = rand::Rng::random(rng);
let seed = tokio::runtime::RngSeed::from_bytes(&bytes);
tokio_builder.rng_seed(seed);
}
Expand Down
6 changes: 3 additions & 3 deletions src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'a> Sim<'a> {
world.register(addr, &nodename, HostTimer::new(self.elapsed), &self.config);
}

let seed = self.world.borrow_mut().rng.gen();
let seed = self.world.borrow_mut().rng.random();
let rng = SmallRng::from_seed(seed);
let config = rt::Config {
enable_io: self.config.enable_tokio_io,
Expand Down Expand Up @@ -131,7 +131,7 @@ impl<'a> Sim<'a> {
world.register(addr, &nodename, HostTimer::new(self.elapsed), &self.config);
}

let seed = self.world.borrow_mut().rng.gen();
let seed = self.world.borrow_mut().rng.random();
let rng = SmallRng::from_seed(seed);
let config = rt::Config {
enable_io: self.config.enable_tokio_io,
Expand Down Expand Up @@ -793,7 +793,7 @@ mod test {
})
};

let construct_a_first = sim.world.borrow_mut().rng.gen_bool(0.5);
let construct_a_first = sim.world.borrow_mut().rng.random_bool(0.5);
if construct_a_first {
make_a(&mut sim);
make_b(&mut sim);
Expand Down
4 changes: 2 additions & 2 deletions src/top.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,13 @@ impl Link {
fn rand_partition(&self, global: &config::MessageLoss, rand: &mut dyn RngCore) -> bool {
let config = self.config.message_loss.as_ref().unwrap_or(global);
let fail_rate = config.fail_rate;
fail_rate > 0.0 && rand.gen_bool(fail_rate)
fail_rate > 0.0 && rand.random_bool(fail_rate)
}

fn rand_repair(&self, global: &config::MessageLoss, rand: &mut dyn RngCore) -> bool {
let config = self.config.message_loss.as_ref().unwrap_or(global);
let repair_rate = config.repair_rate;
repair_rate > 0.0 && rand.gen_bool(repair_rate)
repair_rate > 0.0 && rand.random_bool(repair_rate)
}

fn delay(&self, global: &config::Latency, rand: &mut dyn RngCore) -> Duration {
Expand Down
Loading