Struct yastl::Pool [−][src]
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
impl Pool
[src]
pub fn new(n: usize) -> Self
[src]
pub fn with_config(n: usize, config: ThreadConfig) -> Self
[src]
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.
pub fn spawn<F: FnOnce() + Send + 'static>(&self, job: F)
[src]
Spawn an unscoped job onto this thread pool.
This method doesn’t wait until the job finishes.
pub fn scoped<'scope, F, R>(&self, job: F) -> R where
F: FnOnce(&Scope<'scope>) -> R,
[src]
F: FnOnce(&Scope<'scope>) -> R,
Spawn scoped jobs which guarantee to be finished before this method returns and thus allows to borrow local varaiables.
pub fn shutdown(&self)
[src]
Send a shutdown signal to every worker thread and wait for their termination.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl !UnwindSafe for Pool
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,