pub struct TryJoin<T, E> { /* private fields */ }
Expand description
Concurrently waits for the results of multiple tasks that may return an error.
Implementations§
Source§impl<T, E> TryJoin<T, E>
impl<T, E> TryJoin<T, E>
Sourcepub fn add(&mut self, task: impl Start<Result<T, E>>) -> Index
pub fn add(&mut self, task: impl Start<Result<T, E>>) -> Index
Adds a task to the join, returning its index.
Sourcepub fn add_as(
&mut self,
name: impl Into<SharedString>,
task: impl Start<Result<T, E>>,
) -> Index
pub fn add_as( &mut self, name: impl Into<SharedString>, task: impl Start<Result<T, E>>, ) -> Index
Adds a named task to the join, returning its index.
Sourcepub async fn next(&mut self) -> Option<StoppedTask<T, E>>
pub async fn next(&mut self) -> Option<StoppedTask<T, E>>
Waits for the next stopped task.
If all tasks have stopped, this function returns None
.
Sourcepub async fn try_next(
&mut self,
) -> Option<Result<FinishedTask<T>, FailedTask<E>>>
pub async fn try_next( &mut self, ) -> Option<Result<FinishedTask<T>, FailedTask<E>>>
Waits for the next stopped task and returns its information as a
Result
.
If all tasks have stopped, this function returns None
.
Sourcepub async fn try_drain(&mut self) -> Result<(), FailedTask<E>>
pub async fn try_drain(&mut self) -> Result<(), FailedTask<E>>
Waits for all tasks to stop, dropping their results, until a task fails.
Methods from Deref<Target = Join<Result<T, E>>>§
Sourcepub fn add(&mut self, task: impl Start<T>) -> Index
pub fn add(&mut self, task: impl Start<T>) -> Index
Adds a task to the join, returning its index.
Sourcepub fn add_as(
&mut self,
name: impl Into<SharedString>,
task: impl Start<T>,
) -> Index
pub fn add_as( &mut self, name: impl Into<SharedString>, task: impl Start<T>, ) -> Index
Adds a named task to the join, returning its index.
Sourcepub async fn next(&mut self) -> Option<StoppedTask<Result<T, Panic>>>
pub async fn next(&mut self) -> Option<StoppedTask<Result<T, Panic>>>
Waits for the next stopped task.
If all tasks have stopped, this function returns None
.
Sourcepub async fn try_next(&mut self) -> Option<Result<StoppedTask<T>, PanickedTask>>
pub async fn try_next(&mut self) -> Option<Result<StoppedTask<T>, PanickedTask>>
Waits for the next stopped task and returns its information as a
Result
.
If all tasks have stopped, this function returns None
.
Sourcepub async fn try_drain(&mut self) -> Result<(), PanickedTask>
pub async fn try_drain(&mut self) -> Result<(), PanickedTask>
Waits for all tasks to stop, dropping their results, until a task panics.