mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(cli): event reporting (#2273)
This commit is contained in:
@ -76,6 +76,13 @@ pub trait TaskSpawner: Send + Sync + Unpin + std::fmt::Debug + DynClone {
|
||||
|
||||
/// Spawns a blocking task onto the runtime.
|
||||
fn spawn_blocking(&self, fut: BoxFuture<'static, ()>) -> JoinHandle<()>;
|
||||
|
||||
/// This spawns a critical blocking task onto the runtime.
|
||||
fn spawn_critical_blocking(
|
||||
&self,
|
||||
name: &'static str,
|
||||
fut: BoxFuture<'static, ()>,
|
||||
) -> JoinHandle<()>;
|
||||
}
|
||||
|
||||
dyn_clone::clone_trait_object!(TaskSpawner);
|
||||
@ -97,6 +104,14 @@ impl TaskSpawner for TokioTaskExecutor {
|
||||
fn spawn_blocking(&self, fut: BoxFuture<'static, ()>) -> JoinHandle<()> {
|
||||
tokio::task::spawn_blocking(move || tokio::runtime::Handle::current().block_on(fut))
|
||||
}
|
||||
|
||||
fn spawn_critical_blocking(
|
||||
&self,
|
||||
_name: &'static str,
|
||||
fut: BoxFuture<'static, ()>,
|
||||
) -> JoinHandle<()> {
|
||||
tokio::task::spawn_blocking(move || tokio::runtime::Handle::current().block_on(fut))
|
||||
}
|
||||
}
|
||||
|
||||
/// Many reth components require to spawn tasks for long-running jobs. For example `discovery`
|
||||
@ -353,6 +368,14 @@ impl TaskSpawner for TaskExecutor {
|
||||
fn spawn_blocking(&self, fut: BoxFuture<'static, ()>) -> JoinHandle<()> {
|
||||
self.spawn_blocking(fut)
|
||||
}
|
||||
|
||||
fn spawn_critical_blocking(
|
||||
&self,
|
||||
name: &'static str,
|
||||
fut: BoxFuture<'static, ()>,
|
||||
) -> JoinHandle<()> {
|
||||
TaskExecutor::spawn_critical_blocking(self, name, fut)
|
||||
}
|
||||
}
|
||||
|
||||
/// Determines how a task is spawned
|
||||
|
||||
Reference in New Issue
Block a user