pub struct ThreadManagerRaw<F, T>
where F: Fn() -> T + Send + 'static, T: Send + 'static,
{ /* private fields */ }
Expand description

A thread manager for executing jobs in parallel. This struct manages a pool of worker threads and distributes jobs among them.

§Type Parameters

  • F: The type of the function or closure that the threads will execute.
  • T: The type of the value returned by the function or closure.

§Fields

  • wpc: The number of Workers-Per-Channel.
  • dispatch: An instance of DispatchCycle to manage job distribution.
  • workers: A vector of ThreadWorker instances representing the worker threads.
  • channels: A vector of job channels for dispatching jobs to workers.
  • result_channel: A channel for collecting the results of the jobs.
  • manager_status: An instance of ManagerStatus to track the status of the manager.

Implementations§

source§

impl<F, T> ThreadManagerRaw<F, T>
where F: Fn() -> T + Send + 'static, T: Send + 'static,

source

pub fn new(size: usize) -> Self

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

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

A new instance of ThreadManagerRaw.

source

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

Creates a new instance of ThreadManagerRaw 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 ThreadManagerRaw with the specified configuration.

source

pub fn execute(&self, function: F)

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

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

impl<F, T> ThreadManagerRaw<F, T>
where F: Fn() -> T + Send + 'static, T: Send + 'static,

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

Trait Implementations§

source§

impl<F, T> Drop for ThreadManagerRaw<F, T>
where F: Fn() -> T + Send + 'static, T: Send + 'static,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<F, T> !RefUnwindSafe for ThreadManagerRaw<F, T>

§

impl<F, T> Send for ThreadManagerRaw<F, T>

§

impl<F, T> !Sync for ThreadManagerRaw<F, T>

§

impl<F, T> Unpin for ThreadManagerRaw<F, T>

§

impl<F, T> !UnwindSafe for ThreadManagerRaw<F, 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.