pub struct ThreadManager<T>
where T: Send + 'static,
{ /* private fields */ }
Expand description

A simplified version of ThreadManagerRaw for managing threads that execute functions returning a specific type T.

§Type Parameters

  • T: The type of the value returned by the functions executed by the threads.

Implementations§

source§

impl<T> ThreadManager<T>
where T: Send + 'static,

source

pub fn new(size: usize) -> Self

Creates a new instance of ThreadManager with a specified number of worker threads.

§Arguments
  • size: The number of worker threads to create.
§Returns

A new instance of ThreadManager.

source

pub fn new_asymmetric(size: usize, wpc: usize) -> Self

Creates a new instance of ThreadManager with a specified number of worker threads and a specific workers-per-channel ratio.

§Arguments
  • size: The number of worker threads to create.
  • wpc: The number of workers per channel.
§Returns

A new instance of ThreadManager with the specified configuration.

source

pub fn execute<F>(&self, function: F)
where F: Fn() -> T + Send + 'static,

Executes a given function by sending it to an available worker thread.

§Type Parameters
  • F: The type of the function to execute.
§Arguments
  • function: The function to be executed by the worker thread.
source

pub fn resize(&mut self, size: usize)

Resizes the pool of worker threads.

§Arguments
  • size: The new size of the worker pool.
source

pub fn join(&self)

source

pub fn terminate_all(&self)

source

pub fn job_distribution(&self) -> Vec<usize>

source

pub fn has_finished(&self) -> bool

source

pub fn results<'a>(&'a self) -> ResultIter<'a, T>

source

pub fn yield_results<'a>( &'a self ) -> YieldResultIter<'a, Box<dyn Fn() -> T + Send + 'static>, T>

source

pub fn active_threads(&self) -> usize

source

pub fn busy_threads(&self) -> usize

source

pub fn waiting_threads(&self) -> usize

source

pub fn job_queue(&self) -> usize

source

pub fn sent_jobs(&self) -> usize

source

pub fn received_jobs(&self) -> usize

source

pub fn concluded_jobs(&self) -> usize

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for ThreadManager<T>

§

impl<T> Send for ThreadManager<T>

§

impl<T> !Sync for ThreadManager<T>

§

impl<T> Unpin for ThreadManager<T>

§

impl<T> !UnwindSafe for ThreadManager<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>,

§

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>,

§

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.