Skip to main content

ParallelExecutor

Trait ParallelExecutor 

Source
pub trait ParallelExecutor:
    Send
    + Sync
    + 'static {
    // Required methods
    fn parallelism(&self) -> usize;
    fn try_execute(
        &self,
        job: ParallelJob,
        busy_timeout: Option<Duration>,
    ) -> Result<()>;
}
Expand description

Adapter contract for an application-owned thread pool.

Implementations must either accept job exactly once or return an error without retaining it. busy_timeout lets bounded pools reject work instead of indefinitely waiting for capacity.

Required Methods§

Source

fn parallelism(&self) -> usize

Maximum useful concurrent jobs for this executor.

Source

fn try_execute( &self, job: ParallelJob, busy_timeout: Option<Duration>, ) -> Result<()>

Attempts to schedule one job.

§Errors

Returns an I/O error when the pool is closed, saturated past busy_timeout, or otherwise cannot accept the job.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§