JoinSet

Struct JoinSet 

Source
pub struct JoinSet<T> { /* private fields */ }
Expand description

Same as tokio::task::JoinSet except the number of actively polled futures is limited to a set concurrency.

Does not support spawn_blocking.

For any undocumented methods see tokio::task::JoinSet.

Implementations§

Source§

impl<T> JoinSet<T>

Source

pub const MAX_CONCURRENCY: usize = 2_305_843_009_213_693_951usize

Source

pub fn new(concurrency: usize) -> Self

Creates a new JoinSet with a set concurrency

Panics if concurrency is larger than JoinSet::MAX_CONCURRENCY

Source

pub fn len(&self) -> usize

Returns number of active tasks, queued tasks, and completed tasks

Source

pub fn is_empty(&self) -> bool

Source

pub fn num_active(&self) -> usize

number of futures actively being polled

Source

pub fn num_queued(&self) -> usize

number of tasks which have been pushed to the join set and are waiting to begin work

Source

pub fn num_completed(&self) -> usize

number of tasks that have already been completed but have not been removed from the join set with join_next

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,

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub async fn shutdown(&mut self)

Source

pub fn abort_all(&mut self)

Source

pub fn detach_all(&mut self)

Source

pub fn poll_join_next( &mut self, cx: &mut Context<'_>, ) -> Poll<Option<Result<T, JoinError>>>

Source

pub fn poll_join_next_with_id( &mut self, cx: &mut Context<'_>, ) -> Poll<Option<Result<(Id, T), JoinError>>>

Trait Implementations§

Source§

impl<T> 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

Default concurrency is 8

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.