ThreadGroup

Struct ThreadGroup 

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

ThreadGroup is allows spawning several threads and waiting for their completion through the specialized methods.

Implementations§

Source§

impl<T: Send + Sync + 'static> ThreadGroup<T>

Source

pub fn new() -> ThreadGroup<T>

ThreadGroup::new creates a new thread group

Source

pub fn with_id(id: String) -> ThreadGroup<T>

ThreadGroup::with_id creates a new thread group with a specific id (String)

Source

pub fn spawn<F: FnOnce() -> T + Send + 'static>( &mut self, func: F, ) -> Result<()>

ThreadGroup::spawn spawns a thread

Source

pub fn join(&mut self) -> Result<T>

ThreadGroup::join waits for the first thread to join in blocking fashion, returning the result of that threads FnOnce

Source

pub fn results(&mut self) -> Vec<Result<T>>

ThreadGroup::results waits for the all threads to join in blocking fashion, returning all their results at once as a Vec<Result<T>>

Source

pub fn as_far_as_ok(&mut self) -> Vec<T>

ThreadGroup::as_far_as_ok waits for the all threads to join in blocking fashion, returning all the OK results at once as a Vec<T> but ignoring all errors.

Source

pub fn all_ok(&mut self) -> Result<Vec<T>>

ThreadGroup::all_ok waits for the all threads to join in blocking fashion, returning all the OK results at once as a Vec<T> if there are no errors.

Source

pub fn errors(&self) -> BTreeMap<String, Error>

ThreadGroup::errors returns a BTreeMap<String, Error> of errors whose keys are thread ids that panicked.

Trait Implementations§

Source§

impl<T: Send + Sync + 'static> Default for ThreadGroup<T>

Source§

fn default() -> ThreadGroup<T>

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

impl<T> Display for ThreadGroup<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ThreadGroup<T>

§

impl<T> !RefUnwindSafe for ThreadGroup<T>

§

impl<T> Send for ThreadGroup<T>

§

impl<T> Sync for ThreadGroup<T>

§

impl<T> Unpin for ThreadGroup<T>

§

impl<T> !UnwindSafe for ThreadGroup<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.