pub struct Pool { /* private fields */ }Expand description
A process pool.
This works similar to spawn but lets you retain a pool of processes. Since
procspawn is intended to isolate potentially crashing code the pool will
automatically restart broken processes.
Note that it’s not possible to intercept streams of processes spawned through the pool.
When the process pool is dropped all processes are killed.
This requires the pool feature.
Implementations§
Source§impl Pool
impl Pool
Sourcepub fn builder(size: usize) -> PoolBuilder
pub fn builder(size: usize) -> PoolBuilder
Creates a builder to customize pool creation.
Sourcepub fn queued_count(&self) -> usize
pub fn queued_count(&self) -> usize
Returns the number of jobs waiting to executed in the pool.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Returns the number of currently active threads.
Sourcepub fn spawn<A: Serialize + DeserializeOwned, R: Serialize + DeserializeOwned + Send + 'static>(
&self,
args: A,
func: fn(A) -> R,
) -> JoinHandle<R>
pub fn spawn<A: Serialize + DeserializeOwned, R: Serialize + DeserializeOwned + Send + 'static>( &self, args: A, func: fn(A) -> R, ) -> JoinHandle<R>
Spawns a closure into a process of the pool.
This works exactly like procspawn::spawn but instead
of spawning a new process, it reuses a process from the pool.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Pool
impl RefUnwindSafe for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl UnwindSafe for Pool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more