[−][src]Struct dynpool::Pool
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
Auto Trait Implementations
impl<X> Send for Pool<X> where
X: Send + Sync,
X: Send + Sync,
impl<X> Unpin for Pool<X>
impl<X> Sync for Pool<X> where
X: Send + Sync,
X: Send + Sync,
impl<X> !UnwindSafe for Pool<X>
impl<X> !RefUnwindSafe for Pool<X>
Blanket Implementations
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.
fn to_owned(&self) -> T
[src]
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,