pub struct BlockingExecutor { /* private fields */ }Expand description
A bounded, lazily started executor for synchronous work.
Clones share one pool. Dropping the last executor or calling shutdown
rejects new submissions and fails waiting jobs; running jobs may finish.
The default limits use the available CPU count and four waiting jobs per CPU.
Web submissions return Unsupported without executing the closure.
Implementations§
Source§impl BlockingExecutor
impl BlockingExecutor
Sourcepub fn new(config: BlockingExecutorConfig) -> Self
pub fn new(config: BlockingExecutorConfig) -> Self
Creates an executor without starting threads or reserving queue storage.
Sourcepub fn try_submit<T, F>(
&self,
work: F,
) -> Result<BlockingTask<T>, BlockingError>
pub fn try_submit<T, F>( &self, work: F, ) -> Result<BlockingTask<T>, BlockingError>
Admits work without waiting for capacity, or returns Saturated.
The returned future owns the job: dropping it removes waiting work and releases its captures. A job already taken by a worker may finish.
Sourcepub async fn submit<T, F>(&self, work: F) -> Result<T, BlockingError>
pub async fn submit<T, F>(&self, work: F) -> Result<T, BlockingError>
Waits asynchronously for queue capacity, then runs work and returns its result.
A full queue suspends this future without blocking its polling thread or
returning Saturated. Dropping the future cancels admission or queued work.
Each suspended caller retains its closure until admission or cancellation;
applications should bound the number of concurrent producer tasks.