Split the service initialisation up into seperate functions (#6332)

* Seperate out the complexity in ServiceBuilder::build_common into seperate functions

* Fix line widths

* Move some functions to their respective crates
This commit is contained in:
Ashley
2020-06-16 15:50:21 +02:00
committed by GitHub
parent c44947bbcb
commit 761dbd7dcc
19 changed files with 452 additions and 330 deletions
+4 -1
View File
@@ -358,10 +358,13 @@ impl SpawnBlockingExecutor {
}
#[cfg(feature = "std")]
impl crate::traits::SpawnBlocking for SpawnBlockingExecutor {
impl crate::traits::SpawnNamed for SpawnBlockingExecutor {
fn spawn_blocking(&self, _: &'static str, future: futures::future::BoxFuture<'static, ()>) {
self.0.spawn_ok(future);
}
fn spawn(&self, _: &'static str, future: futures::future::BoxFuture<'static, ()>) {
self.0.spawn_ok(future);
}
}
#[cfg(test)]
+6 -2
View File
@@ -349,10 +349,14 @@ impl TaskExecutorExt {
}
}
/// Something that can spawn a blocking future.
pub trait SpawnBlocking {
/// Something that can spawn futures (blocking and non-blocking) with am assigned name.
pub trait SpawnNamed {
/// Spawn the given blocking future.
///
/// The given `name` is used to identify the future in tracing.
fn spawn_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(&self, name: &'static str, future: futures::future::BoxFuture<'static, ()>);
}