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>
impl<T: Send + Sync + 'static> ThreadGroup<T>
Sourcepub fn new() -> ThreadGroup<T>
pub fn new() -> ThreadGroup<T>
ThreadGroup::new creates a new thread group
Sourcepub fn with_id(id: String) -> ThreadGroup<T>
pub fn with_id(id: String) -> ThreadGroup<T>
ThreadGroup::with_id creates a new thread group with a specific id (String)
Sourcepub fn spawn<F: FnOnce() -> T + Send + 'static>(
&mut self,
func: F,
) -> Result<()>
pub fn spawn<F: FnOnce() -> T + Send + 'static>( &mut self, func: F, ) -> Result<()>
ThreadGroup::spawn spawns a thread
Sourcepub fn join(&mut self) -> Result<T>
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
Sourcepub fn results(&mut self) -> Vec<Result<T>> ⓘ
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>>
Sourcepub fn as_far_as_ok(&mut self) -> Vec<T>
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.
Trait Implementations§
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> 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
Mutably borrows from an owned value. Read more