refactor(tasks): change once! macro to take closure (#22793)

Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
This commit is contained in:
Derek Cofausper
2026-03-04 20:23:40 -08:00
committed by GitHub
parent 7c51bc934c
commit 71c0015862
2 changed files with 3 additions and 3 deletions

View File

@@ -565,7 +565,7 @@ where
let parent_span = Span::current();
self.executor.spawn_blocking_named("sparse-trie", move || {
reth_tasks::once!(increase_thread_priority());
reth_tasks::once!(increase_thread_priority);
let _enter = debug_span!(target: "engine::tree::payload_processor", parent: parent_span, "sparse_trie_task")
.entered();

View File

@@ -2,7 +2,7 @@
pub use thread_priority::{self, *};
/// Runs the given expression exactly once per call site.
/// Runs the given closure exactly once per call site.
///
/// Each invocation expands to its own `static Once`, so two `once!` calls in the same function
/// are independent. Useful for one-time thread setup (priority, affinity) on threads that may
@@ -11,7 +11,7 @@ pub use thread_priority::{self, *};
macro_rules! once {
($e:expr) => {{
static ONCE: std::sync::Once = std::sync::Once::new();
ONCE.call_once(|| $e);
ONCE.call_once($e);
}};
}