mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
refactor(tasks): change once! macro to take closure (#22793)
Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user