Struct cfx_tasks::TaskManager
source · pub struct TaskManager { /* private fields */ }
Expand description
Many reth components require to spawn tasks for long-running jobs. For
example discovery
spawns tasks to handle egress and ingress of udp traffic
or network
that spawns session tasks that handle the traffic to and from a
peer.
To unify how tasks are created, the TaskManager
provides access to the
configured Tokio runtime. A TaskManager
stores the
[tokio::runtime::Handle
] it is associated with. In this way it is possible
to configure on which runtime a task is executed.
The main purpose of this type is to be able to monitor if a critical task
panicked, for diagnostic purposes, since tokio task essentially fail
silently. Therefore, this type is a Stream that yields the name of panicked
task, See TaskExecutor::spawn_critical
. In order to execute Tasks use
the TaskExecutor
type TaskManager::executor
.
Implementations§
source§impl TaskManager
impl TaskManager
sourcepub fn current() -> Self
pub fn current() -> Self
Returns a a TaskManager
over the currently running Runtime.
§Panics
This will panic if called outside the context of a Tokio runtime.
sourcepub fn new(handle: Handle) -> Self
pub fn new(handle: Handle) -> Self
Create a new instance connected to the given handle’s tokio runtime.
sourcepub fn executor(&self) -> TaskExecutor
pub fn executor(&self) -> TaskExecutor
Returns a new TaskExecutor
that can spawn new tasks onto the tokio
runtime this type is connected to.
sourcepub fn graceful_shutdown(self)
pub fn graceful_shutdown(self)
Fires the shutdown signal and awaits until all tasks are shutdown.
sourcepub fn graceful_shutdown_with_timeout(self, timeout: Duration) -> bool
pub fn graceful_shutdown_with_timeout(self, timeout: Duration) -> bool
Fires the shutdown signal and awaits until all tasks are shutdown.
Returns true if all tasks were shutdown before the timeout elapsed.
Trait Implementations§
source§impl Debug for TaskManager
impl Debug for TaskManager
source§impl Future for TaskManager
impl Future for TaskManager
An endless future that resolves if a critical task panicked.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f
. Read more§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read more§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
()
on completion and sends
its output to another future on a separate task. Read more§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.