mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 14:01:06 +00:00
Ensure we spawn the block import worker as an essential task (#8155)
* Ensure we spawn the block import worker as an essential task This pr ensures that we spawn the block import worker as an essential task. This is quite important as we need to bring down the node when the block import is done. Besides that it adds some debug output to the block import worker. * Don't be stupid :D
This commit is contained in:
@@ -152,3 +152,13 @@ impl crate::traits::SpawnNamed for TaskExecutor {
|
||||
self.0.spawn_ok(future);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl crate::traits::SpawnEssentialNamed for TaskExecutor {
|
||||
fn spawn_essential_blocking(&self, _: &'static str, future: futures::future::BoxFuture<'static, ()>) {
|
||||
self.0.spawn_ok(future);
|
||||
}
|
||||
fn spawn_essential(&self, _: &'static str, future: futures::future::BoxFuture<'static, ()>) {
|
||||
self.0.spawn_ok(future);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ sp_externalities::decl_extension! {
|
||||
pub struct RuntimeSpawnExt(Box<dyn RuntimeSpawn>);
|
||||
}
|
||||
|
||||
/// Something that can spawn futures (blocking and non-blocking) with an assigned name.
|
||||
/// Something that can spawn tasks (blocking and non-blocking) with an assigned name.
|
||||
#[dyn_clonable::clonable]
|
||||
pub trait SpawnNamed: Clone + Send + Sync {
|
||||
/// Spawn the given blocking future.
|
||||
@@ -227,3 +227,28 @@ impl SpawnNamed for Box<dyn SpawnNamed> {
|
||||
(**self).spawn(name, future)
|
||||
}
|
||||
}
|
||||
|
||||
/// Something that can spawn essential tasks (blocking and non-blocking) with an assigned name.
|
||||
///
|
||||
/// Essential tasks are special tasks that should take down the node when they end.
|
||||
#[dyn_clonable::clonable]
|
||||
pub trait SpawnEssentialNamed: Clone + Send + Sync {
|
||||
/// Spawn the given blocking future.
|
||||
///
|
||||
/// The given `name` is used to identify the future in tracing.
|
||||
fn spawn_essential_blocking(&self, name: &'static str, future: futures::future::BoxFuture<'static, ()>);
|
||||
/// Spawn the given non-blocking future.
|
||||
///
|
||||
/// The given `name` is used to identify the future in tracing.
|
||||
fn spawn_essential(&self, name: &'static str, future: futures::future::BoxFuture<'static, ()>);
|
||||
}
|
||||
|
||||
impl SpawnEssentialNamed for Box<dyn SpawnEssentialNamed> {
|
||||
fn spawn_essential_blocking(&self, name: &'static str, future: futures::future::BoxFuture<'static, ()>) {
|
||||
(**self).spawn_essential_blocking(name, future)
|
||||
}
|
||||
|
||||
fn spawn_essential(&self, name: &'static str, future: futures::future::BoxFuture<'static, ()>) {
|
||||
(**self).spawn_essential(name, future)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user