Struct sc_service::TaskManager
source · pub struct TaskManager { /* private fields */ }
Expand description
Helper struct to manage background/async tasks in Service.
Implementations§
source§impl TaskManager
impl TaskManager
sourcepub fn new(
tokio_handle: Handle,
prometheus_registry: Option<&Registry>
) -> Result<Self, PrometheusError>
pub fn new( tokio_handle: Handle, prometheus_registry: Option<&Registry> ) -> Result<Self, PrometheusError>
If a Prometheus registry is passed, it will be used to report statistics about the service tasks.
sourcepub fn spawn_handle(&self) -> SpawnTaskHandle
pub fn spawn_handle(&self) -> SpawnTaskHandle
Get a handle for spawning tasks.
sourcepub fn spawn_essential_handle(&self) -> SpawnEssentialTaskHandle
pub fn spawn_essential_handle(&self) -> SpawnEssentialTaskHandle
Get a handle for spawning essential tasks.
sourcepub fn future<'a>(
&'a mut self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
pub fn future<'a>( &'a mut self ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Return a future that will end with success if the signal to terminate was sent
(self.terminate()
) or with an error if an essential task fails.
Warning
This function will not wait until the end of the remaining task.
sourcepub fn keep_alive<T: 'static + Send>(&mut self, to_keep_alive: T)
pub fn keep_alive<T: 'static + Send>(&mut self, to_keep_alive: T)
Set what the task manager should keep alive, can be called multiple times.
sourcepub fn add_child(&mut self, child: TaskManager)
pub fn add_child(&mut self, child: TaskManager)
Register another TaskManager to terminate and gracefully shutdown when the parent
terminates and gracefully shutdown. Also ends the parent future()
if a child’s essential
task fails. (But don’t end the parent if a child’s normal task fails.)
sourcepub fn into_task_registry(self) -> TaskRegistry
pub fn into_task_registry(self) -> TaskRegistry
Consume self
and return the TaskRegistry
.
This TaskRegistry
can be used to check for still running tasks after this task manager
was dropped.
Auto Trait Implementations§
impl !RefUnwindSafe for TaskManager
impl Send for TaskManager
impl !Sync for TaskManager
impl Unpin for TaskManager
impl !UnwindSafe for TaskManager
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.