Struct dynpool::Pool

source ·
pub struct Pool<X> { /* private fields */ }
Expand description

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.

Implementations

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

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.

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.

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.

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.

Has a worker in this pool paniced with unwind?

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.