pub struct TaskExecutionServiceBuilder { /* private fields */ }Expand description
Builder for TaskExecutionService, used to configure the backing super::ThreadPool
before the service is created.
§Design
Configuration is delegated to ThreadPoolBuilder (pool sizes, queue capacity,
thread name prefix, and so on). This type exists so future service-level options
can be added without pushing every thread-pool construction detail onto
TaskExecutionService.
§Relation to TaskExecutionService::builder
TaskExecutionService::builder returns TaskExecutionServiceBuilder::default().
For default pool settings you can use TaskExecutionService::new or
TaskExecutionService::builder().build().
§Example: custom pool, then build the service
use qubit_task::service::{
TaskExecutionServiceBuilder, ThreadPoolBuilder, ExecutorServiceBuilderError,
};
fn main() -> Result<(), ExecutorServiceBuilderError> {
let _service = TaskExecutionServiceBuilder::default()
.thread_pool(
ThreadPoolBuilder::default()
.pool_size(4)
.queue_capacity(256),
)
.build()?;
Ok(())
}Implementations§
Source§impl TaskExecutionServiceBuilder
impl TaskExecutionServiceBuilder
Sourcepub fn thread_pool(self, pool_builder: ThreadPoolBuilder) -> Self
pub fn thread_pool(self, pool_builder: ThreadPoolBuilder) -> Self
Sets the ThreadPoolBuilder used when Self::build creates the pool.
§Example
use qubit_task::service::{
TaskExecutionServiceBuilder, ThreadPoolBuilder, ExecutorServiceBuilderError,
};
fn main() -> Result<(), ExecutorServiceBuilderError> {
let _service = TaskExecutionServiceBuilder::default()
.thread_pool(ThreadPoolBuilder::default().pool_size(2))
.build()?;
Ok(())
}§Parameters
pool_builder- Builder that produces the backingsuper::ThreadPool.
§Returns
self for fluent configuration.
Sourcepub fn build(self) -> Result<TaskExecutionService, ExecutorServiceBuilderError>
pub fn build(self) -> Result<TaskExecutionService, ExecutorServiceBuilderError>
Builds a TaskExecutionService from the current configuration.
§Example
use qubit_task::service::{TaskExecutionServiceBuilder, ExecutorServiceBuilderError};
fn main() -> Result<(), ExecutorServiceBuilderError> {
let _service = TaskExecutionServiceBuilder::default().build()?;
Ok(())
}§Returns
Ok(TaskExecutionService) when ThreadPoolBuilder settings are valid and
workers start successfully; otherwise ExecutorServiceBuilderError.
Trait Implementations§
Source§impl Clone for TaskExecutionServiceBuilder
impl Clone for TaskExecutionServiceBuilder
Source§fn clone(&self) -> TaskExecutionServiceBuilder
fn clone(&self) -> TaskExecutionServiceBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more