Struct yastl::Pool[][src]

pub struct Pool { /* fields omitted */ }

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]

Create a new Pool that will execute it’s tasks on n worker threads.

Panics

If n is zero.

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]

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

impl Clone for Pool[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.