mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: add spawn_critical function to trait (#1622)
This commit is contained in:
@ -70,6 +70,9 @@ pub trait TaskSpawner: Send + Sync + Unpin + std::fmt::Debug + DynClone {
|
|||||||
/// Spawns the task onto the runtime.
|
/// Spawns the task onto the runtime.
|
||||||
/// See also [`Handle::spawn`].
|
/// See also [`Handle::spawn`].
|
||||||
fn spawn(&self, fut: BoxFuture<'static, ()>) -> JoinHandle<()>;
|
fn spawn(&self, fut: BoxFuture<'static, ()>) -> JoinHandle<()>;
|
||||||
|
|
||||||
|
/// This spawns a critical task onto the runtime.
|
||||||
|
fn spawn_critical(&self, name: &'static str, fut: BoxFuture<'static, ()>) -> JoinHandle<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
dyn_clone::clone_trait_object!(TaskSpawner);
|
dyn_clone::clone_trait_object!(TaskSpawner);
|
||||||
@ -83,6 +86,10 @@ impl TaskSpawner for TokioTaskExecutor {
|
|||||||
fn spawn(&self, fut: BoxFuture<'static, ()>) -> JoinHandle<()> {
|
fn spawn(&self, fut: BoxFuture<'static, ()>) -> JoinHandle<()> {
|
||||||
tokio::task::spawn(fut)
|
tokio::task::spawn(fut)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn spawn_critical(&self, _name: &'static str, fut: BoxFuture<'static, ()>) -> JoinHandle<()> {
|
||||||
|
tokio::task::spawn(fut)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Many reth components require to spawn tasks for long-running jobs. For example `discovery`
|
/// Many reth components require to spawn tasks for long-running jobs. For example `discovery`
|
||||||
@ -331,6 +338,10 @@ impl TaskSpawner for TaskExecutor {
|
|||||||
fn spawn(&self, fut: BoxFuture<'static, ()>) -> JoinHandle<()> {
|
fn spawn(&self, fut: BoxFuture<'static, ()>) -> JoinHandle<()> {
|
||||||
self.spawn(fut)
|
self.spawn(fut)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn spawn_critical(&self, name: &'static str, fut: BoxFuture<'static, ()>) -> JoinHandle<()> {
|
||||||
|
TaskExecutor::spawn_critical(self, name, fut)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determines how a task is spawned
|
/// Determines how a task is spawned
|
||||||
|
|||||||
Reference in New Issue
Block a user