pub struct ThreadPoolBuilder { /* private fields */ }Expand description
Determines how a thread pool will behave.
Implementations§
Source§impl ThreadPoolBuilder
impl ThreadPoolBuilder
Sourcepub fn build(self) -> ThreadPool
pub fn build(self) -> ThreadPool
Creates a new ThreadPool initialized using this configuration.
Sourcepub fn build_global(self)
pub fn build_global(self)
Initializes the global thread pool. This initialization is optional. If you do not call this function, the thread pool will be automatically initialized with the default configuration.
Panics if the global thread pool was already initialized.
Sourcepub fn idle_spin_cycles(self, idle_spin_cycles: usize) -> Self
pub fn idle_spin_cycles(self, idle_spin_cycles: usize) -> Self
Threads waiting for work will spin at least this many cycles before sleeping.
Sourcepub fn num_threads(self, num_threads: usize) -> Self
pub fn num_threads(self, num_threads: usize) -> Self
Sets the number of threads to be used in the thread pool.
Sourcepub fn spawn_handler<F>(self, spawn: F) -> Self
pub fn spawn_handler<F>(self, spawn: F) -> Self
Sets a custom function for spawning threads.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ThreadPoolBuilder
impl !RefUnwindSafe for ThreadPoolBuilder
impl !Send for ThreadPoolBuilder
impl !Sync for ThreadPoolBuilder
impl Unpin for ThreadPoolBuilder
impl !UnwindSafe for ThreadPoolBuilder
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