Skip to content

Commit 1a9e08c

Browse files
authored
Use fastrand v2.0.0 (#45)
1 parent 85c20eb commit 1a9e08c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exclude = ["/.*"]
1818
async-lock = "2.6"
1919
async-task = "4.0.0"
2020
concurrent-queue = "2.0.0"
21-
fastrand = "1.3.4"
21+
fastrand = "2.0.0"
2222
futures-lite = "1.11.0"
2323
slab = "0.4.4"
2424

src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,13 @@ impl<'a> Executor<'a> {
227227
/// ```
228228
pub async fn run<T>(&self, future: impl Future<Output = T>) -> T {
229229
let runner = Runner::new(self.state());
230+
let mut rng = fastrand::Rng::new();
230231

231232
// A future that runs tasks forever.
232233
let run_forever = async {
233234
loop {
234235
for _ in 0..200 {
235-
let runnable = runner.runnable().await;
236+
let runnable = runner.runnable(&mut rng).await;
236237
runnable.run();
237238
}
238239
future::yield_now().await;
@@ -748,7 +749,7 @@ impl Runner<'_> {
748749
}
749750

750751
/// Waits for the next runnable task to run.
751-
async fn runnable(&self) -> Runnable {
752+
async fn runnable(&self, rng: &mut fastrand::Rng) -> Runnable {
752753
let runnable = self
753754
.ticker
754755
.runnable_with(|| {
@@ -768,7 +769,7 @@ impl Runner<'_> {
768769

769770
// Pick a random starting point in the iterator list and rotate the list.
770771
let n = local_queues.len();
771-
let start = fastrand::usize(..n);
772+
let start = rng.usize(..n);
772773
let iter = local_queues
773774
.iter()
774775
.chain(local_queues.iter())

0 commit comments

Comments
 (0)