use crate::{
modules::{errors::RuntimeError, tuning::Tuning},
runtime::Runtime,
};
pub struct RuntimeBuilder {
tuning: Tuning,
}
impl RuntimeBuilder {
pub(crate) const fn new() -> Self {
Self {
tuning: Tuning::new(),
}
}
pub fn workers_per_core(mut self, count: usize) -> Self {
self.tuning.set_workers_per_core(count);
self
}
pub fn sleep_threads_per_core(mut self, count: usize) -> Self {
self.tuning.set_sleep_threads_per_core(count);
self
}
pub fn worker_stack(mut self, bytes: usize) -> Self {
self.tuning.set_worker_stack(bytes);
self
}
pub fn init(self) -> Result<(), RuntimeError> {
self.tuning.check()?;
Runtime::init_with(self.tuning)
}
}
impl Default for RuntimeBuilder {
fn default() -> Self {
Self::new()
}
}