pub struct ThreadPool { /* private fields */ }Expand description
Thread pool for parallel task execution
Implementations§
Source§impl ThreadPool
impl ThreadPool
Sourcepub fn new(num_threads: usize) -> UtilsResult<Self>
pub fn new(num_threads: usize) -> UtilsResult<Self>
Create a new thread pool with the specified number of threads
Sourcepub fn with_cpu_cores() -> UtilsResult<Self>
pub fn with_cpu_cores() -> UtilsResult<Self>
Create a thread pool with number of threads equal to CPU cores
Sourcepub fn execute<F>(&self, f: F) -> UtilsResult<()>
pub fn execute<F>(&self, f: F) -> UtilsResult<()>
Submit a job to the thread pool
Sourcepub fn thread_count(&self) -> usize
pub fn thread_count(&self) -> usize
Get the number of worker threads
Trait Implementations§
Source§impl Debug for ThreadPool
impl Debug for ThreadPool
Auto Trait Implementations§
impl Freeze for ThreadPool
impl !RefUnwindSafe for ThreadPool
impl Send for ThreadPool
impl Sync for ThreadPool
impl Unpin for ThreadPool
impl !UnwindSafe for ThreadPool
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more