use super::pool; use super::JoinHandle; use crate::future::Future; use crate::io; /// Task builder that configures the settings of a new task. #[derive(Debug, Default)] pub struct Builder { pub(crate) name: Option, } impl Builder { /// Creates a new builder. pub fn new() -> Builder { Builder { name: None } } /// Configures the name of the task. pub fn name(mut self, name: String) -> Builder { self.name = Some(name); self } /// Spawns a task with the configured settings. pub fn spawn(self, future: F) -> io::Result> where F: Future + Send + 'static, T: Send + 'static, { Ok(pool::get().spawn(future, self)) } }