Struct JoinSet

Source
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>

Source

pub fn new() -> Self

JoinSet::new - Create a new JoinSet.

Source

pub fn len(&self) -> usize

JoinSet::len - Return the number of tasks.

Source

pub fn is_empty(&self) -> bool

JoinSet::is_empty - Check if the JoinSet is empty.

Source§

impl<T: 'static> JoinSet<T>

Source

pub fn spawn<F>(&mut self, task: F) -> AbortHandle
where F: Future<Output = T> + Send + 'static, T: Send,

JoinSet::spawn - Spawn a new task.

Source

pub fn spawn_on<F>(&mut self, task: F, handle: &Handle) -> AbortHandle
where F: Future<Output = T> + Send + 'static, T: Send,

JoinSet::spawn_on - Spawn a task on a provided runtime.

Source

pub fn spawn_local<F>(&mut self, task: F) -> AbortHandle
where F: Future<Output = T> + 'static,

JoinSet::spawn_local - Spawn a local task.

Source

pub fn spawn_local_on<F>( &mut self, task: F, local_set: &LocalSet, ) -> AbortHandle
where F: Future<Output = T> + 'static,

JoinSet::spawn_local_on - Spawn a local task on a provided LocalSet.

Source

pub fn spawn_blocking<F>(&mut self, f: F) -> AbortHandle
where F: FnOnce() -> T + Send + 'static, T: Send,

JoinSet::spawn_blocking - Spawn a blocking task.

Source

pub fn spawn_blocking_on<F>(&mut self, f: F, handle: &Handle) -> AbortHandle
where F: FnOnce() -> T + Send + 'static, T: Send,

JoinSet::spawn_blocking_on - Spawn a blocking task on a provided runtime.

Source

pub async fn join_next(&mut self) -> Option<Result<T, JoinError>>

JoinSet::join_next - Await the next completed task.

Source

pub fn try_join_next(&mut self) -> Option<Result<T, JoinError>>

JoinSet::try_join_next - Try to join the next completed task.

Source

pub fn abort_all(&mut self)

JoinSet::abort_all - Abort all tasks.

Source

pub fn detach_all(&mut self)

JoinSet::detach_all - Detach all tasks.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn shutdown(&mut self)

JoinSet::shutdown - Abort all tasks and wait for shutdown.

Source

pub async fn join_all(self) -> Vec<T>

JoinSet::join_all - Await all tasks.

Trait Implementations§

Source§

impl<T: Debug> Debug for JoinSet<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for JoinSet<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.