pub struct ThreadPool { /* private fields */ }Expand description
Thread pool for executing tasks
Implementations§
Source§impl ThreadPool
impl ThreadPool
Sourcepub fn new(num_threads: usize) -> Result<Self>
pub fn new(num_threads: usize) -> Result<Self>
Create a new thread pool with default configuration
Sourcepub fn with_config(config: ThreadPoolConfig) -> Result<Self>
pub fn with_config(config: ThreadPoolConfig) -> Result<Self>
Create a thread pool with custom configuration
Sourcepub fn execute<F>(&self, f: F) -> Result<()>
pub fn execute<F>(&self, f: F) -> Result<()>
Execute a task in the thread pool (fire-and-forget)
Sourcepub fn submit<F, T>(&self, f: F) -> Result<WorkResult<T>>
pub fn submit<F, T>(&self, f: F) -> Result<WorkResult<T>>
Submit a task that returns a value
Sourcepub fn parallel_for_each<T, F>(&self, items: Vec<T>, f: F) -> Result<()>
pub fn parallel_for_each<T, F>(&self, items: Vec<T>, f: F) -> Result<()>
Execute work in parallel using rayon (native only)
Sourcepub fn parallel_map<T, R, F>(&self, items: Vec<T>, f: F) -> Result<Vec<R>>
pub fn parallel_map<T, R, F>(&self, items: Vec<T>, f: F) -> Result<Vec<R>>
Map operation in parallel (native only)
Sourcepub fn num_threads(&self) -> usize
pub fn num_threads(&self) -> usize
Get the number of worker threads
Sourcepub fn pending_tasks(&self) -> usize
pub fn pending_tasks(&self) -> usize
Get pending task count
Sourcepub fn shutdown_timeout(self, timeout: Duration) -> Result<()>
pub fn shutdown_timeout(self, timeout: Duration) -> Result<()>
Shutdown and wait with timeout
Auto Trait Implementations§
impl !RefUnwindSafe for ThreadPool
impl !UnwindSafe for ThreadPool
impl Freeze for ThreadPool
impl Send for ThreadPool
impl Sync for ThreadPool
impl Unpin for ThreadPool
impl UnsafeUnpin 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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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