Skip to content

Commit

Permalink
Update clippy allows and use const in thread local
Browse files Browse the repository at this point in the history
  • Loading branch information
Pi-Cla committed Nov 19, 2024
1 parent d422915 commit 32e8ff9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::future::Future;
pub(crate) static GLOBAL_EXECUTOR: Executor<'_> = Executor::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
Expand Down
6 changes: 3 additions & 3 deletions src/threading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static GLOBAL_EXECUTOR_EXPECTED_THREADS_NUMBER: Mutex<usize> = 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.
Expand Down Expand Up @@ -84,7 +84,7 @@ fn thread_main_loop() {

// Main loop
loop {
#[allow(clippy::blocks_in_if_conditions)]
#[allow(clippy::blocks_in_conditions)]
if std::panic::catch_unwind(|| {
crate::executor::LOCAL_EXECUTOR.with(|executor| {
let local = executor.run(async {
Expand All @@ -111,7 +111,7 @@ fn thread_main_loop() {

fn wait_for_local_executor_completion() {
loop {
#[allow(clippy::blocks_in_if_conditions)]
#[allow(clippy::blocks_in_conditions)]
if std::panic::catch_unwind(|| {
crate::executor::LOCAL_EXECUTOR.with(|executor| {
crate::reactor::block_on(async {
Expand Down

0 comments on commit 32e8ff9

Please sign in to comment.