use super::config::{CleanupConfig, ExecutorConfig, MemoryConfig, PreemptionConfig};
use crate::platform::String;
pub struct ExecutorBuilder {
pub(crate) config: ExecutorConfig,
}
impl ExecutorBuilder {
#[must_use]
pub fn new() -> Self {
Self {
config: ExecutorConfig::default(),
}
}
#[must_use]
pub fn worker_threads(mut self, count: usize) -> Self {
self.config.worker_threads = count;
self
}
#[must_use]
pub fn async_threads(mut self, count: usize) -> Self {
self.config.async_threads = count;
self
}
#[must_use]
pub fn max_global_queue_size(mut self, size: usize) -> Self {
self.config.max_global_queue_size = size;
self
}
#[must_use]
pub fn max_local_queue_size(mut self, size: usize) -> Self {
self.config.max_local_queue_size = size;
self
}
#[must_use]
pub fn thread_name_prefix(mut self, prefix: impl Into<String>) -> Self {
self.config.thread_name_prefix = prefix.into();
self
}
#[cfg(feature = "numa")]
#[must_use]
pub fn numa_aware(mut self, enabled: bool) -> Self {
self.config.numa_aware = enabled;
self
}
#[cfg(feature = "metrics")]
#[must_use]
pub fn enable_metrics(mut self, enabled: bool) -> Self {
self.config.enable_metrics = enabled;
self
}
#[must_use]
pub fn preemption_config(mut self, config: PreemptionConfig) -> Self {
self.config.preemption = config;
self
}
#[must_use]
pub fn memory_config(mut self, config: MemoryConfig) -> Self {
self.config.memory = config;
self
}
#[must_use]
pub fn cleanup_config(mut self, config: CleanupConfig) -> Self {
self.config.cleanup = config;
self
}
}
impl Default for ExecutorBuilder {
fn default() -> Self {
Self::new()
}
}