fn start(&mut self, limit: Option<usize>) -> Result<(), Box<dyn Error>>
  where
    Self: 'static + Sized,
  {
    let hostname = hostname::get().unwrap_or_else(|_| OsString::from("hostname")).into_string().unwrap();
    match self.pool_size() {
      1 => {
        self.set_identity(format!("{}:engrafo:1", hostname));
        self.start_single(limit)
      }
      n => {
        let mut threads = Vec::new();
        for thread in 1..=n {
          let thread_str = if thread < 10 {
            format!("0{}", thread)
          } else {
            thread.to_string()
          };
          let identity_single = format!("{}:engrafo:{}", hostname, thread_str);
          let mut thread_self: Self = self.clone();
          thread_self.set_identity(identity_single);
          threads.push(thread::spawn(move || {
            // TODO: Errors can not be shared between threads safely? What should be the robustness strategy here?
            thread_self.start_single(limit).unwrap();
          }));
        }
        for t in threads {
          t.join().unwrap();
        }
        Ok(())
      }
    }
  }
/// sets up the worker process, with as many threads as requested
sets up the worker process, with as many threads as requested
sets up the worker process with as many threads as requested
fn start(&mut self, limit: Option<usize>) -> Result<(), Box<dyn Error>>
  where
    Self: 'static + Sized,
  {
    let hostname = hostname::get().unwrap_or_else(|_| OsString::from("hostname")).into_string().unwrap();
    match self.pool_size() {
      1 => {
        self.set_identity(format!("{}:engrafo:1", hostname));
        self.start_single(limit)
      }
      n => {
        let mut threads = Vec::new();
        for thread in 1..=n {
          let thread_str = if thread < 10 {
            format!("0{}", thread)
          } else {
            thread.to_string()
          };
          let identity_single = format!("{}:engrafo:{}", hostname, thread_str);
          let mut thread_self: Self = self.clone();
          thread_self.set_identity(identity_single);
          threads.push(thread::spawn(move || {
            // TODO: Errors can not be shared between threads safely? What should be the robustness strategy here?
            thread_self.start_single(limit).unwrap();
          }));
        }
        for t in threads {
          t.join().unwrap();
        }
        Ok(())
      }
    }
  }
fn start ( & mut self , limit : Option < usize > ) -> Result < ( ) , Box < dyn Error > > where Self : ' static + Sized , { let hostname = hostname :: get ( ) . unwrap_or_else ( | _ | OsString :: from ( " " ) ) . into_string ( ) . unwrap ( ) ; match self . pool_size ( ) { 1 => { self . set_identity ( format ! ( " " hostname ) ) ; self . start_single ( limit ) } n => { let mut threads = Vec :: new ( ) ; for thread in 1 ..= n { let thread_str = if thread < 10 { format ! ( " " thread ) } else { thread . to_string ( ) } ; let identity_single = format ! ( " " hostname thread_str ) ; let mut thread_self : Self = self . clone ( ) ; thread_self . set_identity ( identity_single ) ; threads . push ( thread :: spawn ( move | | { // TODO: Errors can not be shared between threads safely? What should be the robustness strategy here? thread_self . start_single ( limit ) . unwrap ( ) ; } ) ) ; } for t in threads { t . join ( ) . unwrap ( ) ; } Ok ( ( ) ) } } }
sets up the worker process, with as many threads as requested
sets up the worker process with as many threads as requested
&mut self
limit
Option<usize>
&mut self
limit
Option<usize>