From 7ec898f775e026a1df9097f3664c2a58211bf6d1 Mon Sep 17 00:00:00 2001 From: Jacob Rothstein Date: Tue, 28 May 2024 11:59:09 -0700 Subject: [PATCH] feat: use async_executor::StaticExecutor --- Cargo.toml | 2 +- src/executor.rs | 6 +++--- src/threading.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b753964..5fb5b7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ tokio03 = ["tokio03-crate"] [dependencies] async-channel = "^2.1.1" -async-executor = "^1.8" +async-executor = { version = "^1.12", features = ["static"] } async-lock = "^3.2" blocking = "^1.5" futures-lite = "^2.0" diff --git a/src/executor.rs b/src/executor.rs index 838fbd6..f032755 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -1,11 +1,11 @@ use crate::Task; -use async_executor::{Executor, LocalExecutor}; +use async_executor::{LocalExecutor, StaticExecutor}; use std::future::Future; -pub(crate) static GLOBAL_EXECUTOR: Executor<'_> = Executor::new(); +pub(crate) static GLOBAL_EXECUTOR: StaticExecutor = StaticExecutor::new(); thread_local! { - pub(crate) static LOCAL_EXECUTOR: LocalExecutor<'static> = LocalExecutor::new(); + pub(crate) static LOCAL_EXECUTOR: LocalExecutor<'static> = const { LocalExecutor::new() }; } /// Runs the global and the local executor on the current thread diff --git a/src/threading.rs b/src/threading.rs index ed8b549..7f29305 100644 --- a/src/threading.rs +++ b/src/threading.rs @@ -13,7 +13,7 @@ static GLOBAL_EXECUTOR_EXPECTED_THREADS_NUMBER: Mutex = Mutex::new(0); thread_local! { // Used to shutdown a thread when we receive a message from the Sender. // We send an ack using to the Receiver once we're finished shutting down. - static THREAD_SHUTDOWN: OnceCell<(Sender<()>, Receiver<()>)> = OnceCell::new(); + static THREAD_SHUTDOWN: OnceCell<(Sender<()>, Receiver<()>)> = const { OnceCell::new() }; } /// Spawn more executor threads, up to configured max value.