pub struct ErrSpawnGroup<ValueType, ErrorType> {
pub is_cancelled: bool,
/* private fields */
}Expand description
Err Spawn Group
A kind of a spawn group that spawns asynchronous child tasks that returns a value of Result<ValueType, ErrorType>,
that implicitly wait for the spawned tasks to return before being dropped unless by
explicitly calling dont_wait_at_drop()
Child tasks are spawned by calling either spawn_task() or spawn_task_unless_cancelled() methods.
Running child tasks can be cancelled by calling cancel_all() method.
Child tasks spawned to a spawn group execute concurrently, and may be scheduled in any order.
It dereferences into a futures crate Stream type where the results of each finished child task is stored and it pops out the result in First-In First-Out
FIFO order whenever it is being used
Fields§
§is_cancelled: boolA field that indicates if the spawn group had been cancelled
Implementations§
Source§impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
Source§impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
Sourcepub fn dont_wait_at_drop(&mut self)
pub fn dont_wait_at_drop(&mut self)
Don’t implicity wait for spawned child tasks to finish before being dropped
Source§impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
Sourcepub fn spawn_task<F>(&mut self, priority: Priority, closure: F)
pub fn spawn_task<F>(&mut self, priority: Priority, closure: F)
Spawns a new task into the spawn group
§Parameters
priority: priority to useclosure: an async closure that return a value of typeResult<ValueType, ErrorType>
Sourcepub fn cancel_all(&mut self)
pub fn cancel_all(&mut self)
Cancels all running task in the spawn group
Sourcepub fn spawn_task_unlessed_cancelled<F>(
&mut self,
priority: Priority,
closure: F,
)
pub fn spawn_task_unlessed_cancelled<F>( &mut self, priority: Priority, closure: F, )
Spawn a new task only if the group is not cancelled yet, otherwise does nothing
§Parameters
priority: priority to useclosure: an async closure that return a value of typeResult<ValueType, ErrorType>
Source§impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
Source§impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
Source§impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
Sourcepub async fn wait_for_all(&mut self)
pub async fn wait_for_all(&mut self)
Waits for all remaining child tasks for finish.
Sourcepub fn wait_non_async(&mut self)
pub fn wait_non_async(&mut self)
Waits for all remaining child tasks for finish in non async context.
Source§impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
A Boolean value that indicates whether the group has any remaining tasks.
At the start of the body of a with_err_spawn_group function call, or before calling spawn_task or spawn_task_unless_cancelled methods
the spawn group is always empty.
§Returns
- true: if there’s no child task still running
- false: if any child task is still running
Source§impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> ErrSpawnGroup<ValueType, ErrorType>
Sourcepub async fn get_chunks(
&self,
of_count: usize,
) -> Vec<Result<ValueType, ErrorType>>
👎Deprecated since 2.0.0: Buggy
pub async fn get_chunks( &self, of_count: usize, ) -> Vec<Result<ValueType, ErrorType>>
Waits for a specific number of spawned child tasks to finish and returns their respectively result as a vector
§Panics
If the of_count parameter is larger than the number of already spawned child tasks, this method panics
Remember whenever you call either wait_for_all or cancel_all methods, the child tasks’ count reverts back to zero
§Parameter
of_count: The number of running child tasks to wait for their results to return
§Returns
Returns a vector of length of_count elements from the spawn group instance
Trait Implementations§
Source§impl<ValueType, ErrorType> Default for ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> Default for ErrSpawnGroup<ValueType, ErrorType>
Source§impl<ValueType, ErrorType> Drop for ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> Drop for ErrSpawnGroup<ValueType, ErrorType>
Source§impl<ValueType, ErrorType> Stream for ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> Stream for ErrSpawnGroup<ValueType, ErrorType>
Auto Trait Implementations§
impl<ValueType, ErrorType> Freeze for ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> !RefUnwindSafe for ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> Send for ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> Sync for ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> Unpin for ErrSpawnGroup<ValueType, ErrorType>
impl<ValueType, ErrorType> !UnwindSafe for ErrSpawnGroup<ValueType, ErrorType>
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> GetType for Twhere
T: ?Sized,
impl<T> GetType for Twhere
T: ?Sized,
Source§const TYPE: PhantomData<Self> = PhantomData
const TYPE: PhantomData<Self> = PhantomData
Source§impl<S> StreamExt for S
impl<S> StreamExt for S
Source§fn next(&mut self) -> NextFuture<'_, Self>where
Self: Unpin,
fn next(&mut self) -> NextFuture<'_, Self>where
Self: Unpin,
Source§fn try_next<T, E>(&mut self) -> TryNextFuture<'_, Self>
fn try_next<T, E>(&mut self) -> TryNextFuture<'_, Self>
Source§fn count(self) -> CountFuture<Self>where
Self: Sized,
fn count(self) -> CountFuture<Self>where
Self: Sized,
Source§fn map<T, F>(self, f: F) -> Map<Self, F>
fn map<T, F>(self, f: F) -> Map<Self, F>
Source§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
Source§fn then<F, Fut>(self, f: F) -> Then<Self, F, Fut>
fn then<F, Fut>(self, f: F) -> Then<Self, F, Fut>
Source§fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>
fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>
Source§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
n items of the stream. Read moreSource§fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
Source§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n items of the stream. Read moreSource§fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
Source§fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
stepth item. Read moreSource§fn chain<U>(self, other: U) -> Chain<Self, U>
fn chain<U>(self, other: U) -> Chain<Self, U>
Source§fn collect<C>(self) -> CollectFuture<Self, C>
fn collect<C>(self) -> CollectFuture<Self, C>
Source§fn try_collect<T, E, C>(self) -> TryCollectFuture<Self, C>
fn try_collect<T, E, C>(self) -> TryCollectFuture<Self, C>
Source§fn partition<B, P>(self, predicate: P) -> PartitionFuture<Self, P, B>
fn partition<B, P>(self, predicate: P) -> PartitionFuture<Self, P, B>
predicate is true and those for which it is
false, and then collects them into two collections. Read moreSource§fn fold<T, F>(self, init: T, f: F) -> FoldFuture<Self, F, T>
fn fold<T, F>(self, init: T, f: F) -> FoldFuture<Self, F, T>
Source§fn try_fold<T, E, F, B>(
&mut self,
init: B,
f: F,
) -> TryFoldFuture<'_, Self, F, B>
fn try_fold<T, E, F, B>( &mut self, init: B, f: F, ) -> TryFoldFuture<'_, Self, F, B>
Source§fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
Source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
(index, item). Read moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn nth(&mut self, n: usize) -> NthFuture<'_, Self>where
Self: Unpin,
fn nth(&mut self, n: usize) -> NthFuture<'_, Self>where
Self: Unpin,
nth item of the stream. Read moreSource§fn last(self) -> LastFuture<Self>where
Self: Sized,
fn last(self) -> LastFuture<Self>where
Self: Sized,
Source§fn find<P>(&mut self, predicate: P) -> FindFuture<'_, Self, P>
fn find<P>(&mut self, predicate: P) -> FindFuture<'_, Self, P>
Source§fn find_map<F, B>(&mut self, f: F) -> FindMapFuture<'_, Self, F>
fn find_map<F, B>(&mut self, f: F) -> FindMapFuture<'_, Self, F>
Source§fn position<P>(&mut self, predicate: P) -> PositionFuture<'_, Self, P>
fn position<P>(&mut self, predicate: P) -> PositionFuture<'_, Self, P>
Source§fn for_each<F>(self, f: F) -> ForEachFuture<Self, F>
fn for_each<F>(self, f: F) -> ForEachFuture<Self, F>
Source§fn try_for_each<F, E>(&mut self, f: F) -> TryForEachFuture<'_, Self, F>
fn try_for_each<F, E>(&mut self, f: F) -> TryForEachFuture<'_, Self, F>
Source§fn zip<U>(self, other: U) -> Zip<Self, U>
fn zip<U>(self, other: U) -> Zip<Self, U>
Source§fn unzip<A, B, FromA, FromB>(self) -> UnzipFuture<Self, FromA, FromB>
fn unzip<A, B, FromA, FromB>(self) -> UnzipFuture<Self, FromA, FromB>
Source§fn race<S>(self, other: S) -> Race<Self, S>
fn race<S>(self, other: S) -> Race<Self, S>
other stream, with no preference for either stream when both are ready. Read more