From 449dbe167db49f427f4498594498e874768c953f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Rica=20Pais=20da=20Silva?= Date: Mon, 6 Nov 2023 15:58:36 +0100 Subject: [PATCH 1/2] Use once_cell instead of async-lock --- Cargo.toml | 3 +-- src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8023362..c28b4d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,11 +15,11 @@ categories = ["asynchronous", "concurrency"] exclude = ["/.*"] [dependencies] -async-lock = "3.0.0" async-task = "4.0.0" concurrent-queue = "2.0.0" fastrand = "2.0.0" futures-lite = { version = "2.0.0", default-features = false } +once_cell = "1.18.0" slab = "0.4.4" [dev-dependencies] @@ -30,7 +30,6 @@ easy-parallel = "3.1.0" event-listener = "3.0.0" fastrand = "2.0.0" futures-lite = "2.0.0" -once_cell = "1.16.0" [[bench]] name = "executor" diff --git a/src/lib.rs b/src/lib.rs index 79428cd..0400c85 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,7 +35,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::{Arc, Mutex, RwLock, TryLockError}; use std::task::{Poll, Waker}; -use async_lock::OnceCell; +use once_cell::sync::OnceCell; use async_task::Runnable; use concurrent_queue::ConcurrentQueue; use futures_lite::{future, prelude::*}; @@ -263,7 +263,7 @@ impl<'a> Executor<'a> { /// Returns a reference to the inner state. fn state(&self) -> &Arc { - self.state.get_or_init_blocking(|| Arc::new(State::new())) + self.state.get_or_init(|| Arc::new(State::new())) } } From c8dc824ebb9c7162692639523c6a2c195b8f3600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Rica=20Pais=20da=20Silva?= Date: Mon, 6 Nov 2023 16:20:25 +0100 Subject: [PATCH 2/2] cargo fmt --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0400c85..b331a03 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,10 +35,10 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::{Arc, Mutex, RwLock, TryLockError}; use std::task::{Poll, Waker}; -use once_cell::sync::OnceCell; use async_task::Runnable; use concurrent_queue::ConcurrentQueue; use futures_lite::{future, prelude::*}; +use once_cell::sync::OnceCell; use slab::Slab; #[doc(no_inline)]