Struct xstream_util::Limiting
source · pub struct Limiting<C> { /* private fields */ }
Expand description
A pool to manage spawning a limited number of processses
This will wait for the oldest scheduled process to complete before scheduling a new one. If you schedule a long running process, then a bunch of short ones, it won’t schedule more short ones beyond the buffer until the long one has finished.
Implementations§
Trait Implementations§
source§impl<C: BorrowMut<Command>> Pool for Limiting<C>
impl<C: BorrowMut<Command>> Pool for Limiting<C>
source§fn get(&mut self) -> Result<&mut Child, Error>
fn get(&mut self) -> Result<&mut Child, Error>
Spawn a new process with command and return a mutable reference to the process
This command will block until it can schedule the process under the constraints. It can fail for any reason, including an earlier process failed, and never actually spawn the process in question. If it does successfully spawn the process, it will be recorded so that it will be cleaned up if the pool is dropped.
source§fn join(&mut self) -> Result<(), Error>
fn join(&mut self) -> Result<(), Error>
Wait for all processes to finish
Errors will terminate early and not wait for reamining processes to finish. To continue waiting for them anyway you can continue to call join until you get a success, this will indicate that there are no more running processes under management by the pool.