pub struct Pool { /* private fields */ }
Expand description
A structure providing access to a pool of worker threads and a way to spawn jobs.
It spawns n
threads at creation and then can be used to spawn scoped threads via
Pool::scoped()
or unscoped threads via Pool::spawn()
.
Implementations§
source§impl Pool
impl Pool
sourcepub fn with_config(n: usize, config: ThreadConfig) -> Self
pub fn with_config(n: usize, config: ThreadConfig) -> Self
Create a new Pool
that will execute it’s tasks on n
worker threads and spawn them using
the given config.
§Panics
If n
is zero.
sourcepub fn spawn<F: FnOnce() + Send + 'static>(&self, job: F)
pub fn spawn<F: FnOnce() + Send + 'static>(&self, job: F)
Spawn an unscoped job onto this thread pool.
This method doesn’t wait until the job finishes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pool
impl RefUnwindSafe for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl UnwindSafe for Pool
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)