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() -> JoinSet<T>
pub fn new() -> JoinSet<T>
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> JoinSet<T>where
T: 'static,
impl<T> JoinSet<T>where
T: 'static,
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.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for JoinSet<T>
impl<T> RefUnwindSafe for JoinSet<T>
impl<T> Send for JoinSet<T>where
T: Send,
impl<T> Sync for JoinSet<T>where
T: Send,
impl<T> Unpin for JoinSet<T>
impl<T> UnwindSafe for JoinSet<T>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more