[][src]Struct dynpool::Pool

pub struct Pool<X> { /* fields omitted */ }

A handle to a lightweight thread pool. This is the primary type in the dynpool crate.

Pools spawn and close threads in LIFO (last spawned is first destroyed) order. A worker (the context of execution bound to each thread) can be restarted by issuing a Restart decision, but the thread itself will only shutdown if the scale is decreased.

Methods

impl<X: System> Pool<X>[src]

pub fn start_bg(sys: X) -> Pool<X>[src]

Create a new manager which runs the given system in the background, starting a new thread for each worker.

pub fn start_fg(sys: X) -> Result<(), PoolPanicedError>[src]

Create a new manager which runs the given system in the foreground, using the current thread to host the first worker. It will return when all workers have shutdown.

If a worker panics with unwind, then this function will return Err(PoolPanicedError) instantly, even if some workers are still completing work. Due to limitations in std, It is undefined behavior for a worker to panic with abort.

pub fn swap_system<Y: System>(&self, sys: Y) -> Pool<Y>[src]

Gracefully change the system that this pool executes, and slowly replace all workers. This does not destroy the system or this handle. It simply tells threads to work on new tasks. A new pool handle is returned.

pub fn system(&self) -> &X[src]

Get a reference to the system associated with this pool handle. This system is not necessarily receiving work, since a different system may have been swapped onto the pool.

pub fn thread_count(&self) -> usize[src]

Number of running threads. Note that since threads can spawn and close at any time as a result of queries to System::scale, this count may not be correct.

pub fn has_paniced(&self) -> bool[src]

Has a worker in this pool paniced with unwind?

pub fn join(self) -> Result<(), PoolPanicedError>[src]

Block until all workers have shutdown.

If a worker panics with unwind, then this function will return Err(PoolPanicedError) instantly, even if some workers are still completing work. Due to limitations in std, It is undefined behavior for a worker to panic with abort. In such a case, join will likely never return.

Trait Implementations

impl<X> Clone for Pool<X>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<X> Send for Pool<X> where
    X: Send + Sync

impl<X> Unpin for Pool<X>

impl<X> Sync for Pool<X> where
    X: Send + Sync

impl<X> !UnwindSafe for Pool<X>

impl<X> !RefUnwindSafe for Pool<X>

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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

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.

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]