Struct xstream_util::Rotating

source ·
pub struct Rotating<C> { /* private fields */ }
Expand description

A pool to manage spawning a limited number of processses

This pool will return new processes up to the limit, and then start returning old processes in a round-robin order. This type of pool is more effective if the process handles each task by delimiters as well, allowing for better utilization of resources for embarassingly parallel tasks.

Implementations§

source§

impl<C: BorrowMut<Command>> Rotating<C>

source

pub fn new(command: C, max_procs: usize) -> Self

Create a new empty pool with a limited number of total processes

Set max_procs to 0 to enable unbounded parallelism.

Trait Implementations§

source§

impl<C: Debug> Debug for Rotating<C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<C> Drop for Rotating<C>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<C: BorrowMut<Command>> Pool for Rotating<C>

source§

fn get(&mut self) -> Result<&mut Child, Error>

Get a process from the pool

If fewer than max_procs have been spawned, this will spawn a new process, otherwise it will return one that was already spawned.

source§

fn join(&mut self) -> Result<(), Error>

Wait for all processes to finish successfully

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.

Auto Trait Implementations§

§

impl<C> RefUnwindSafe for Rotating<C>
where C: RefUnwindSafe,

§

impl<C> Send for Rotating<C>
where C: Send,

§

impl<C> Sync for Rotating<C>
where C: Sync,

§

impl<C> Unpin for Rotating<C>
where C: Unpin,

§

impl<C> UnwindSafe for Rotating<C>
where C: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.