Use fastrand v2.0.0 (#45)

This commit is contained in:
John Nunley 2023-06-09 17:53:03 -07:00 committed by GitHub
parent 85c20eb98b
commit 1a9e08ce73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -18,7 +18,7 @@ exclude = ["/.*"]
async-lock = "2.6"
async-task = "4.0.0"
concurrent-queue = "2.0.0"
fastrand = "1.3.4"
fastrand = "2.0.0"
futures-lite = "1.11.0"
slab = "0.4.4"

View File

@ -227,12 +227,13 @@ impl<'a> Executor<'a> {
/// ```
pub async fn run<T>(&self, future: impl Future<Output = T>) -> T {
let runner = Runner::new(self.state());
let mut rng = fastrand::Rng::new();
// A future that runs tasks forever.
let run_forever = async {
loop {
for _ in 0..200 {
let runnable = runner.runnable().await;
let runnable = runner.runnable(&mut rng).await;
runnable.run();
}
future::yield_now().await;
@ -748,7 +749,7 @@ impl Runner<'_> {
}
/// Waits for the next runnable task to run.
async fn runnable(&self) -> Runnable {
async fn runnable(&self, rng: &mut fastrand::Rng) -> Runnable {
let runnable = self
.ticker
.runnable_with(|| {
@ -768,7 +769,7 @@ impl Runner<'_> {
// Pick a random starting point in the iterator list and rotate the list.
let n = local_queues.len();
let start = fastrand::usize(..n);
let start = rng.usize(..n);
let iter = local_queues
.iter()
.chain(local_queues.iter())