pub struct JoinSet<T> { /* private fields */ }
Expand description
A wrapper around Tokio’s JoinSet that forwards all API calls while optionally
instrumenting spawned tasks and blocking closures with custom tracing behavior.
If no tracer is injected via trace_utils::set_tracer
, tasks and closures are executed
without any instrumentation.
Implementations§
Source§impl<T> JoinSet<T>
impl<T> JoinSet<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
JoinSet::new - Create a new JoinSet.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
JoinSet::len - Return the number of tasks.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
JoinSet::is_empty - Check if the JoinSet is empty.
Source§impl<T: 'static> JoinSet<T>
impl<T: 'static> JoinSet<T>
Sourcepub fn spawn<F>(&mut self, task: F) -> AbortHandle
pub fn spawn<F>(&mut self, task: F) -> AbortHandle
JoinSet::spawn - Spawn a new task.
Sourcepub fn spawn_on<F>(&mut self, task: F, handle: &Handle) -> AbortHandle
pub fn spawn_on<F>(&mut self, task: F, handle: &Handle) -> AbortHandle
JoinSet::spawn_on - Spawn a task on a provided runtime.
Sourcepub fn spawn_local<F>(&mut self, task: F) -> AbortHandlewhere
F: Future<Output = T> + 'static,
pub fn spawn_local<F>(&mut self, task: F) -> AbortHandlewhere
F: Future<Output = T> + 'static,
JoinSet::spawn_local - Spawn a local task.
Sourcepub fn spawn_local_on<F>(
&mut self,
task: F,
local_set: &LocalSet,
) -> AbortHandlewhere
F: Future<Output = T> + 'static,
pub fn spawn_local_on<F>(
&mut self,
task: F,
local_set: &LocalSet,
) -> AbortHandlewhere
F: Future<Output = T> + 'static,
JoinSet::spawn_local_on - Spawn a local task on a provided LocalSet.
Sourcepub fn spawn_blocking<F>(&mut self, f: F) -> AbortHandle
pub fn spawn_blocking<F>(&mut self, f: F) -> AbortHandle
JoinSet::spawn_blocking - Spawn a blocking task.
Sourcepub fn spawn_blocking_on<F>(&mut self, f: F, handle: &Handle) -> AbortHandle
pub fn spawn_blocking_on<F>(&mut self, f: F, handle: &Handle) -> AbortHandle
JoinSet::spawn_blocking_on - Spawn a blocking task on a provided runtime.
Sourcepub async fn join_next(&mut self) -> Option<Result<T, JoinError>>
pub async fn join_next(&mut self) -> Option<Result<T, JoinError>>
JoinSet::join_next - Await the next completed task.
Sourcepub fn try_join_next(&mut self) -> Option<Result<T, JoinError>>
pub fn try_join_next(&mut self) -> Option<Result<T, JoinError>>
JoinSet::try_join_next - Try to join the next completed task.
Sourcepub fn abort_all(&mut self)
pub fn abort_all(&mut self)
JoinSet::abort_all - Abort all tasks.
Sourcepub fn detach_all(&mut self)
pub fn detach_all(&mut self)
JoinSet::detach_all - Detach all tasks.
Sourcepub fn poll_join_next(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<T, JoinError>>>
pub fn poll_join_next( &mut self, cx: &mut Context<'_>, ) -> Poll<Option<Result<T, JoinError>>>
JoinSet::poll_join_next - Poll for the next completed task.
Sourcepub async fn join_next_with_id(&mut self) -> Option<Result<(Id, T), JoinError>>
pub async fn join_next_with_id(&mut self) -> Option<Result<(Id, T), JoinError>>
JoinSet::join_next_with_id - Await the next completed task with its ID.
Sourcepub fn try_join_next_with_id(&mut self) -> Option<Result<(Id, T), JoinError>>
pub fn try_join_next_with_id(&mut self) -> Option<Result<(Id, T), JoinError>>
JoinSet::try_join_next_with_id - Try to join the next completed task with its ID.
Sourcepub fn poll_join_next_with_id(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<(Id, T), JoinError>>>
pub fn poll_join_next_with_id( &mut self, cx: &mut Context<'_>, ) -> Poll<Option<Result<(Id, T), JoinError>>>
JoinSet::poll_join_next_with_id - Poll for the next completed task with its ID.
Sourcepub async fn shutdown(&mut self)
pub async fn shutdown(&mut self)
JoinSet::shutdown - Abort all tasks and wait for shutdown.
Sourcepub async fn join_all(self) -> Vec<T>
pub async fn join_all(self) -> Vec<T>
JoinSet::join_all - Await all tasks.