pub struct TerminableThreads<T, const N: usize> { /* private fields */ }
Expand description
A basic thread manager that can signal all threads to terminate / finish early
Note that threads will only terminate if the Arc<AtomicBool>
flag is used
Implementations§
Source§impl<T, const N: usize> TerminableThreads<T, N>
impl<T, const N: usize> TerminableThreads<T, N>
pub fn build() -> (TerminableThreadsBuilder<T, N>, Arc<AtomicBool>)
Sourcepub fn terminate(&self)
pub fn terminate(&self)
Signal all threads to terminate and cease operation
§Note
This does not guarantee all threads will terminate, or can be terminated.
Threads will only terminate if the underlying function checks the flag passed to it.s
Sourcepub fn join(
self,
signal_terminate: bool,
) -> [Result<T, Box<dyn Any + Send + 'static>>; N]
pub fn join( self, signal_terminate: bool, ) -> [Result<T, Box<dyn Any + Send + 'static>>; N]
Join all threads, optionally signalling termination
Optional termination signalling is useful because no termination signal will let allow a function to run until it has finished naturally, while early termination could stop operations earlier than wanted
§Returns
[Result<T, Error>; N]
An array of length N containing the results of joining each thread
Trait Implementations§
Auto Trait Implementations§
impl<T, const N: usize> Freeze for TerminableThreads<T, N>
impl<T, const N: usize> !RefUnwindSafe for TerminableThreads<T, N>
impl<T, const N: usize> Send for TerminableThreads<T, N>
impl<T, const N: usize> Sync for TerminableThreads<T, N>
impl<T, const N: usize> Unpin for TerminableThreads<T, N>
impl<T, const N: usize> !UnwindSafe for TerminableThreads<T, N>
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