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
Creates a builder to customize pool creation.
Returns the number of jobs waiting to executed in the pool.
Returns the number of currently active threads.
pub 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.