pub struct ThreadPoolBuilder<S = GlobalQueueMode> { /* private fields */ }Expand description
A builder for configuring and creating a thread pool.
This uses a typed-state builder pattern to enforce proper configuration.
Implementations§
Source§impl<S> ThreadPoolBuilder<S>
impl<S> ThreadPoolBuilder<S>
Sourcepub fn with_metrics_collector(
self,
collector: Arc<dyn MetricsCollector>,
) -> Self
pub fn with_metrics_collector( self, collector: Arc<dyn MetricsCollector>, ) -> Self
Adds a metrics collector to the builder.
§Arguments
collector: AnArc<dyn MetricsCollector>for monitoring the thread pool’s behavior.
Sourcepub fn num_threads(self, n: usize) -> Self
pub fn num_threads(self, n: usize) -> Self
Sets the number of threads for the thread pool.
§Arguments
n: The number of threads to create in the thread pool.
Source§impl ThreadPoolBuilder<DefaultModeState>
impl ThreadPoolBuilder<DefaultModeState>
Sourcepub fn set_work_stealing(self) -> ThreadPoolBuilder<WorkStealingState>
pub fn set_work_stealing(self) -> ThreadPoolBuilder<WorkStealingState>
Configures the builder to enable work-stealing mode.
Sourcepub fn enable_priority(self) -> ThreadPoolBuilder<PriorityState>
pub fn enable_priority(self) -> ThreadPoolBuilder<PriorityState>
Configures the builder to enable priority-based task scheduling.
Sourcepub fn build(self) -> ThreadPool<GlobalQueueMode>
pub fn build(self) -> ThreadPool<GlobalQueueMode>
Builds the thread pool with the default global queue mode.
Source§impl ThreadPoolBuilder<WorkStealingState>
impl ThreadPoolBuilder<WorkStealingState>
Sourcepub fn enable_priority(self) -> ThreadPoolBuilder<PriorityWorkStealingState>
pub fn enable_priority(self) -> ThreadPoolBuilder<PriorityWorkStealingState>
Configures the builder to enable priority-based task scheduling.
Sourcepub fn build(self) -> ThreadPool<WorkStealingMode>
pub fn build(self) -> ThreadPool<WorkStealingMode>
Builds the thread pool with work-stealing mode.
Source§impl ThreadPoolBuilder<PriorityState>
impl ThreadPoolBuilder<PriorityState>
Sourcepub fn build(self) -> ThreadPool<PriorityGlobalQueueMode>
pub fn build(self) -> ThreadPool<PriorityGlobalQueueMode>
Builds the thread pool with priority global queue mode.
Source§impl ThreadPoolBuilder<PriorityWorkStealingState>
impl ThreadPoolBuilder<PriorityWorkStealingState>
Sourcepub fn build(self) -> ThreadPool<PriorityWorkStealingMode>
pub fn build(self) -> ThreadPool<PriorityWorkStealingMode>
Builds the thread pool with priority work-stealing mode.
Auto Trait Implementations§
impl<S> Freeze for ThreadPoolBuilder<S>
impl<S = GlobalQueueMode> !RefUnwindSafe for ThreadPoolBuilder<S>
impl<S> Send for ThreadPoolBuilder<S>where
S: Send,
impl<S> Sync for ThreadPoolBuilder<S>where
S: Sync,
impl<S> Unpin for ThreadPoolBuilder<S>where
S: Unpin,
impl<S = GlobalQueueMode> !UnwindSafe for ThreadPoolBuilder<S>
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